javascript - Idiom to get just the "own object" and not the prototype chain -
is there recognised idiom own-object in javascript? i.e. chop off prototype chain object, in ie10 , above.
function o() { this.foo = 'foo'; } o.prototype = { bar: 'bar' } var o = new o(); for(var v in o) { console.log(v); // foo bar } // ...but want object representing own properties , values o.__proto__ = null; // need work in ie10 for(var v in o) { console.log(v); // foo }
you using object.getownpropertynames() or object.keys().
function o() { this.foo = 'foo'; } o.prototype = { bar: 'bar' } var o = new o(); for(var v in o) { console.log(v); // foo bar } object.getownpropertynames(o).foreach(function(val, idx, array) { console.log("getownpropertynames() " + val); }); object.keys(o).foreach(function(val, idx, array) { console.log("keys() " + val); });
Comments
Post a Comment