Jump to content

Bare object with no prototype


graduate

Recommended Posts

I don't understand what you mean. Everything in Javascript has a prototype. A bare object would be:

var a = new Object();

It's going to inherit everything that's in the Object()'s prototype.

Link to comment
Share on other sites

I guess you'll have to make a new type of object for that.I can't be sure this will work for all browsers:

function BareObject() {  this.toString = null;  this.constructor = null;  this.toLocaleString = null;  this.valueOf = null;  this.hasOwnProperty = null;  this.isPrototypeOf = null;  this.propertyIsEnumerable = null;}var a = new BareObject();

But why do you want an object without a prototype? I can't imagine any situation where you would need it. You can always override any methods you want to.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...