Created
August 3, 2011 15:42
-
-
Save tj/1122942 to your computer and use it in GitHub Desktop.
less retarded js prototypes
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
var User = { | |
toString: function(){ | |
return '<User ' + this.name + '>' | |
} | |
}; | |
var Admin = { __proto__: User, isAdmin: true }; | |
var tj = { __proto__: Admin }; | |
tj.name = 'tj'; | |
console.log(tj.toString()); | |
// => <User tj> | |
console.log(tj.isAdmin); | |
// => true |
Kind of like Lua metatables. :)
yeah if this was the norm and performant I would be one happy camper. Would be nice if proto was just proto
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If ECMA standardized
__proto__
, I might agree with them on something.