Created
November 2, 2012 17:36
-
-
Save nathanaschbacher/4002983 to your computer and use it in GitHub Desktop.
Javascript instance to instance coercion
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
var inspect = require('util').inspect; | |
var Class1 = function Class1() { | |
this.frank = "costanza"; | |
this.__defineGetter__('prop', function() {return 5;}); | |
this.__defineGetter__('fromClass1', function() {return 5;}); | |
} | |
Class1.prototype.heyThere = function() {} | |
var Class2 = function Class2() { | |
this.frank = "brasky"; | |
} | |
Class2.highlevel = function() {}; | |
Class2.prototype.seehere = null; | |
var c1 = new Class1(); | |
var c2 = new Class2(); | |
console.log(inspect(c1, true, null, null)); | |
c2.__proto__ = c1; | |
console.log(inspect(c2, true, null, null)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment