Skip to content

Instantly share code, notes, and snippets.

@sym3tri
Last active January 10, 2019 09:14
Show Gist options
  • Save sym3tri/4162830 to your computer and use it in GitHub Desktop.
Save sym3tri/4162830 to your computer and use it in GitHub Desktop.
Explanation of prototypes
// 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