gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 09:22:48 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com