Nicholas Nicholas - 3 months ago 3x
Javascript Question

Javascript : What is the difference between $(function () {}); and function () {}

What is the difference between

$(function () {
/* some functionality */


function () {
/* some functionality */

I've seen the first one used to initialize bootstraps tooltip (for eg.) but I tried the same with the second function it doesn't work. Can someone help me out please?


The first one, in jquery, is a shorthand for $(document).ready(function(){}).