I learn JavaScript and play with it. Why I get false
instead of true
in my code of property owner searching? What is my mistake?
/* Get the object containing the property. */
Object.prototype.where = function (propName){ return this.hasOwnProperty(propName) ? this :
(this.constructor.prototype ? null : this.where.bind(this.constructor.prototype, propName)());};
let a = {foo : 123}, b = Object.create(a), c = a == b.where('foo');
process.stdout.write(c.toString()); // false