indexOf
有哪些方法可以恢复console.log(a.indexOf("two")); // output = 1
的功能?
Format$(Sheet1.Range("A1").Value,"yyyy-mm-dd")
答案 0 :(得分:1)
您只需重新分配来自Array.prototype
的原始函数。
var a = ["one", "two", "three"];
console.log(a.indexOf("two")); // output = 1
a.indexOf = function(val) {
return 'HAHAHA';
};
console.log(a.indexOf("two")); // output = 'HAHAHA'
a.indexOf = Array.prototype.indexOf; // re-assign the original function
// which is inherited from Array.prototype.
console.log(a.indexOf("two")); // output = 1