我希望能够增加Array.prototype
方法,然后在任何数组上调用它们:
>>> [1, 2, 3].customMethod();
但似乎数组没有原型......?
>>> [1, 2, 3].prototype
undefined
我在这里错过了什么吗?
看来我的实际问题出在其他地方:调用[1, 2, 3].customMethod()
有效,但调用someDomElement.childNodes.customMethod()
失败。是childNodes
不是真正的数组?
childNodes.filter is not a function