I would like to hide all the default methods like toString, hasOwnProperty, valueOf etcetera when creating an instance. How is this possible?
function Foo() {};
var x = new Foo();
x.toString(); //should fail
And additionaly; I can understand that if I do this, I cannot do the following:
console.log(x);
But what else is using these functions?
If you really wanted to you could write over the toString
method:
Foo.prototype.toString = undefined;