Are these code rows equal in a sense? Are exist the hidden differences in their operation?
$(document).ready(_ => alert('Hello'));
$(_ => alert('Hello'));
Are these code rows equal in a sense? Are exist the hidden differences in their operation?
$(document).ready(_ => alert('Hello'));
$(_ => alert('Hello'));
They are exactly the same. Here are the lines from jQuery() function.
// ...
// HANDLE: $(function)
// Shortcut for document ready
} else if ( jQuery.isFunction( selector ) ) {
return root.ready !== undefined ?
root.ready( selector ) :
// Execute immediately if ready is not present
selector( jQuery );
}
So you can see, if you provide a function to $() or jQuery() as a first argument, it will act as a shortcut for $(document).ready