Skip to content

Instantly share code, notes, and snippets.

@edfuh
Created September 21, 2011 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edfuh/1233020 to your computer and use it in GitHub Desktop.
Save edfuh/1233020 to your computer and use it in GitHub Desktop.
No methods in constructor, no properties in prototype
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