What is the non-jQuery equivalent of ‘$(document).ready()’?

This works perfectly, from ECMA. The snippet is all you need, but if you want to dig more and explore other options check this detailed explanation. The window.onload doesn’t equal to JQuery $(document).ready because $(document).ready waits only to the DOM tree while window.onload check all elements including external assets and images. EDIT: Added IE8 and older equivalent, thanks to Jan Derk‘s observation. You may read … Read more

stopPropagation vs. stopImmediatePropagation

stopPropagation will prevent any parent handlers from being executed stopImmediatePropagation will prevent any parent handlers and also any other handlers from executing Quick example from the jquery documentation: Note that the order of the event binding is important here! Show code snippet

JavaScript: function returning an object

In JavaScript, most functions are both callable and instantiable: they have both a [[Call]] and [[Construct]] internal methods. As callable objects, you can use parentheses to call them, optionally passing some arguments. As a result of the call, the function can return a value. The code above calls function makeGamePlayer and stores the returned value in the variable player. In this case, you may want … Read more