stuart-d2
12/30/2014 - 2:07 PM

Create Javascript Object -- Object.create() function

Create Javascript Object -- Object.create() function

var a = Object.create(null, { a:   { value: 1}, b: { value:2 }}); // no prototype
var b = Object.create({}, {a: {value: "a" }, b: { value: "b" }}); // prototype is an empty obj
var c = Obect.create({}, { a: { value:true }, b: { value: false }});  // prototype is an empty obj

console.log(a.a); // outputs 1
console.log(a.b); // outputs 2
console.log(b.a);  // outputs a
console.log(b.b); // outbuts b
console.log(c.a); // outputs true
console.log(c.b); // outputs false