Created
September 26, 2015 20:02
-
-
Save qetr1ck-op/aadce099bb5b8ddf7a02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Rabbit(name) { | |
this.name = name; | |
} | |
Rabbit.prototype.sayHi = function() { | |
console.log( this.name ); | |
} | |
var rabbit = new Rabbit('Rabbit'); | |
rabbit.sayHi(); // (1) ? | |
Rabbit.prototype.sayHi(); // (2) ? | |
Object.getPrototypeOf(rabbit).sayHi(); // (3) ? | |
rabbit.__proto__.sayHi(); // (4) ? | |
//(1) 'Rabbit', following the rule of "this - is the object before the point." | |
//this === rabbit | |
//(2-4) undefined, this === Rabbit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment