我正在检查一些JS库代码并且知道他们正在使用原型函数从主对象Object.prototype.toString.call(a, this)(这里是一个对象).那么有可能null在主要的Object原型中分配,比如Object.prototype = null?
Object.prototype 不可写.所以不行.事实上,没有任何内置原型是可写的.
你可以在这里试试:
console.log(typeof Object.prototype.toString); //"function"
Object.prototype = null;
console.log(typeof Object.prototype.toString); //not nullified - still "function"
console.log(typeof String.prototype.substring); //"function"
String.prototype = null;
console.log(typeof String.prototype.substring); //sameRun Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
83 次 |
| 最近记录: |