Created
December 6, 2012 10:23
-
-
Save matjaz/4223508 to your computer and use it in GitHub Desktop.
What does "this.hello = this.hello;" do?
This file contains 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 O1() { | |
} | |
function O2() { | |
// what does this line do? | |
this.hello = this.hello; | |
} | |
O1.prototype.hello = O2.prototype.hello = function() { | |
console.log('hello'); | |
}; | |
var o1 = new O1(), | |
o2 = new O2(); | |
o1.hello(); // hello | |
o2.hello(); // hello | |
// so what does it do? | |
console.log(o1.hasOwnProperty('hello')); // false | |
console.log(o2.hasOwnProperty('hello')); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment