Last active
January 10, 2019 10:10
-
-
Save vivektikar25/bd08d791d91d6063d8f2ea8503393bab to your computer and use it in GitHub Desktop.
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 objA = {foo:"foo"}; | |
var objB = {bar:"bar"}; | |
var objC = {baz:"baz"}; | |
objA.__proto__ = objB; | |
objB.__proto__ = objC; | |
console.log(objA.bar); | |
console.log(objA.baz); | |
// ============================================================== // | |
var objA = {foo:"foo"}; | |
var objB = {bar:"bar"}; | |
var objC = {baz:"baz"}; | |
objB.__proto__ = objA; | |
objC.__proto__ = objA; | |
console.log(objB.bar); | |
console.log(objC.baz); | |
// ============================================================== // | |
// Object Literal | |
var objA = {}; | |
console.log(objA); | |
// ============================================================== // | |
// Object.create() | |
var objA = {foo:"bar"}; | |
var objB = Object.create(objA); | |
objB; | |
// ============================================================== // | |
// Constructor Function | |
function person(firstName, lastName){ | |
this.firstName = firstName; | |
this.lastName = lastName; | |
}; | |
person.prototype | |
var p1 = new person("Srinivasa", "Ramanujan"); | |
p1.__proto__; | |
person.prototype.baz = "bam"; | |
person.prototype; | |
p1.__proto__; | |
person.prototype === p1.__proto__; | |
person.prototype = {foo:"bar"}; | |
var p2 = new person("Thomos", "Edison"); | |
p2.__proto__; | |
var num = 15; | |
var strNum = num.toString(); | |
console.log(strNum); | |
num.__proto__; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment