> String.prototype.repeat = function(times) { ... return new Array(times+1).join(this) ... } [Function] > undefined > "hello".repeat(3) >
> z = Object.create({x:1, y:2}) {} > z.x > z.y > z.__proto__ > z.__proto__.__proto__ > z.__proto__.__proto__.__proto__
> obj = {x : 'something' } { x: 'something' } > w = Object.create(obj) {} > w.x 'something' > w.x = "another thing" 'another thing' > w.__proto__ > obj == w.__proto__
> obj = {x : { y : 1} } { x: { y: 1 } } > w = Object.create(obj) {} > w.x == obj.x true > w.x.y = 2 2 > obj { x: { y: 2 } } >
> inherit = Object.create [Function: create] > o = {} {} > o.x = 1 1 > p = inherit(o) {} > p.x 1 > p.y = 2 2 > p { y: 2 } > o { x: 1 } > o.y undefined > q = inherit(p) {} > q.z = 3 3 > q { z: 3 } > s = q.toString() '[object Object]' > q.x+q.y+q.z 6 > o.x 1 > o.x = 4 4 > p.x 4 > q.x 4 > q.x = 5 5 > p.x 4 > o.x 4