Skip to content

Instantly share code, notes, and snippets.

@rupeshtiwari
Last active August 13, 2018 18:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rupeshtiwari/fb9add642fde66f85894bd57bed22f5f to your computer and use it in GitHub Desktop.
Save rupeshtiwari/fb9add642fde66f85894bd57bed22f5f to your computer and use it in GitHub Desktop.
JavaScript Concepts
log();
var log = function(msg) {
alert(msg);
}
/*
* in this case log function is a expression type and log varibale will be hoisted at the top
* and initialized with undefined therefore, we will get
* Uncaught TypeError: log is not a function
*/
// in below example log function will be called since all of the function declarations are hoinsted at the top before runing code.
log();
function log(msg) {
alert(msg);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment