我有一个 MSDN document for Array.removeAt()功能。
但是当我尝试它时,我收到了这个错误:“Uncaught TypeError: Array.removeAt is not a function”,
var a = ['a', 'b', 'c', 'd', 'e'];
Array.removeAt(a, 2);
console.log(a);
为什么它在这里不起作用?那是一份错误的文件吗?
编辑 a.removeAt(a, 2);
也不起作用。
var a = ['a', 'b', 'c', 'd', 'e'];
a.removeAt(a, 2);
console.log(a);
最佳答案
JavaScript 中没有Array.removeAt()
函数.
MSDN article is an out of date reference to a JScript (not JavaScript) function.
或者,您可以使用 Array.splice()
或其他一些类似的函数。
有关更多信息,请查看此处:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
关于javascript - "Uncaught TypeError: Array.removeAt() is not a function",,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50501112/