javascript - "Uncaught TypeError: Array.removeAt() is not a function",

标签 javascript arrays typescript msdn

我有一个 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/

相关文章:

typescript - 在另一个 `await` 函数内调用 `async` 函数时,应该使用 `async` 吗?

typescript - 如何正确输入 fp-ts ObservableEither#fold?

arrays - Typescript - 对通用数组进行排序

javascript - 如何检查单选按钮是否被选中,然后检查下一个单选按钮并显示不同的内容?

javascript - 使用键作为变量的 Angular 翻译不起作用

javascript - 服务器端 CSV 文件将其转换为 JavaScript 数组

javascript - 我可以让 Flash 影片与 Shadowbox jquery 覆盖进行通信吗?

ios - 如何将 CSV 数据解析为 App UI 的 XCode

c++ - 按下回车键时停止将值输入数组

javascript - 按对象属性的键对对象数组进行排序