Overwrite Object function didn't affect {} expression?
I overwrite the Object constructor:
function Object() {
console.log("here");
}
when I call var x = new Object();
, I can see "here".
var x = {};
, I can't got it.
开发者_运维问答Isn't {}
the same as new Object()
? How can I get this work?using object() creates new function with name object with scope on document object, actually does not override object. While using var x = {}, it use original JS object.
精彩评论