Skip to content

Instantly share code, notes, and snippets.

@ppraksa
Last active March 22, 2017 13:38
Show Gist options
  • Save ppraksa/b07eb678f85350be4812f1b18496880d to your computer and use it in GitHub Desktop.
Save ppraksa/b07eb678f85350be4812f1b18496880d to your computer and use it in GitHub Desktop.
"to hoist or not to hoist"
var cat = new Cat() // it's ok !
cat.sayHello(); // then we call sayHello without any problem!
function Cat() {
this.sayHello = function() {
console.log('hello Im a cat');
}
}
var dog = new Dog(); // ref error wtf?
dog.SayHello();
class Dog {
sayHello() {
console.log('hello Im a dog');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment