Created
October 29, 2010 23:46
-
-
Save mde/654680 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
node> var parentFunc = function () { this.a = []; }; | |
node> typeof parentFunc; | |
'function' | |
node> var foo = new parentFunc(); | |
node> foo; | |
{ a: [] } | |
node> var subFunc = function () {}; | |
node> subFunc.prototype = foo; | |
{ a: [] } | |
node> var bar = new subFunc(); | |
node> bar.a; | |
[] | |
node> bar.a === foo.a; | |
true | |
node> var baz = new subFunc(); | |
node> baz.a.push(1); | |
1 | |
node> var otherSubFunc = subFunc; | |
node> foo.a; | |
[ 1 ] | |
node> bar.a; | |
[ 1 ] | |
node> baz.a; | |
[ 1 ] | |
node> bar.a = 'howdy'; | |
'howdy' | |
node> foo.a; | |
[ 1 ] | |
node> bar.a; | |
'howdy' | |
node> baz.a; | |
[ 1 ] | |
node> bar; | |
{ a: 'howdy' } | |
node> baz; | |
{} | |
node> baz.a | |
[ 1 ] | |
node> var parentFunc = function () { this.b = {howdy: 'HOWDY'} }; | |
node> foo; | |
{ a: [ 1 ] } | |
node> foo; | |
{ a: [ 1 ] } | |
node> bar; | |
{ a: 'howdy' } | |
node> delete bar.a; | |
true | |
node> bar; | |
{} | |
node> bar.a; | |
[ 1 ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment