Last active
January 10, 2019 09:14
-
-
Save sym3tri/4162830 to your computer and use it in GitHub Desktop.
Explanation of prototypes
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
// http://dailyjs.com/2012/11/26/js101-proto/ | |
var assert = require('assert'); | |
function User() { | |
} | |
var user = new User(); | |
assert.equal(user.__proto__, User.prototype); | |
assert.equal(user.constructor, User); | |
assert.equal(user.constructor.prototype, User.prototype); | |
assert.equal(user.constructor.prototype, user.__proto__); | |
assert.equal(Object.getPrototypeOf(user), User.prototype); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment