> z { x: 3, y: 1 } > Object.keys(z) ????? > Object.keys(z).forEach(function(i) { console.log(i+" -> "+z[i]); }) ?????
z
?
> z { x: 2, y: 1 } > Object.defineProperty(z, 'y', {writable : false}) { x: 2, y: 1 } > z.x = 3 ?????? > z.y = 2 ?????? > z
> obj = { x : 1, y : 2} { x: 1, y: 2 } > bValue = 5 5 > Object.defineProperty(obj, "b", {get: function(){ return bValue; }, set: function(y){ bValue = y; }}) { x: 1, y: 2 } > obj.b = "hello" > bValue > obj.b > bValue = "world" > obj.b >
> var o = {}; undefined > Object.defineProperty(o, "a", { value : 1, enumerable:true }); { a: 1 } > Object.defineProperty(o, "b", { value : 2, enumerable:false }); { a: 1 } > Object.defineProperty(o, "c", { value : 3 }); // enumerable defaults to false { a: 1 } > o.d = 4; // enumerable defaults to true when creating a property by setting it 4 > undefined > for (var i in o) { ... console.log(i); ... } ??????? > Object.keys(o); ??????? > o.propertyIsEnumerable('a'); ???? > o.propertyIsEnumerable('b'); ???? > o.propertyIsEnumerable('c'); ???? > o.b ???? > o["b"] ????
> function foo(a, b){return a * b;} undefined > f = function foo(a, b){return a * b;} [Function: foo] > foo.length 2 > foo.constructor [Function: Function] > foo.prototype {} > typeof foo.prototype 'object' > [1, 2].constructor [Function: Array]
> Object.getPrototypeOf({ a: 1}) > Object.getPrototypeOf([1,2,3]) > Object.getPrototypeOf([1,2,3]) == Array.prototype > Object.getPrototypeOf({ a:1 }) === Object.prototype > Object.getPrototypeOf(Array.prototype) > Object.getPrototypeOf(Object.prototype) > Object.getPrototypeOf(function() {}) > Object.getPrototypeOf(Object.getPrototypeOf(function() {})) > [1,2,3].__proto__ > [1,2,3].__proto__ == Array.prototype
var b = new Foo(20); var c = new Foo(30);