Created
September 21, 2011 19:14
-
-
Save edfuh/1233020 to your computer and use it in GitHub Desktop.
No methods in constructor, no properties in prototype
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 Class = function () { | |
this.a = 'abc'; | |
this.b = 666; | |
this.c = function () { | |
return 3 * 3; | |
}; | |
} | |
Class.prototype.d = function () { | |
return 2 + 2; | |
}; | |
Class.prototype.e = []; | |
var obj1 = new Class; | |
obj1.e.push(1); | |
console.log(obj1.e) // [1] | |
for (var i in obj1) | |
if (obj1.hasOwnProperty(i)) | |
console.log(i, typeof obj1[i]) // a string, b number, c function | |
var obj2 = new Class; | |
obj2.e.push(1); | |
console.log(obj2.e) // [1, 1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment