javascript - Is there a way to hide Object.prototype's property? -
if add property object.prototype object.prototype.sth = "something";
then, there way hide property specified object? tried this:
function foo() { // sth... } foo.prototype = null; var bar = new foo(); however, bar still have access property sth;
bar.__proto__ = null or foo.prototype.__proto__ = null works
i think way is:
function foo() { this.sth = null // or this.sth = undefined; } var bar = new foo(); foo.prototype = null;:bar.__proto__point directlyobject.prototype.- without
foo.prototype = null;:bar.__proto__pointfoo.prototype, ,foo.prototype.__proto__pointsobject.prototype
another way:
function foo() { // sth... } foo.prototype.sth = undefined; //or foo.prototype.sth = null; var bar = new foo();
Comments
Post a Comment