admin管理员组文章数量:1353114
I got a MSDN document for Array.removeAt() function.
But when i trying it, I am getting this error : "Uncaught TypeError: Array.removeAt is not a function",
var a = ['a', 'b', 'c', 'd', 'e'];
Array.removeAt(a, 2);
console.log(a);
I got a MSDN document for Array.removeAt() function.
But when i trying it, I am getting this error : "Uncaught TypeError: Array.removeAt is not a function",
var a = ['a', 'b', 'c', 'd', 'e'];
Array.removeAt(a, 2);
console.log(a);
Why it's not working here? And is that is a wrong document?
Edit: a.removeAt(a, 2);
also not working.
var a = ['a', 'b', 'c', 'd', 'e'];
a.removeAt(a, 2);
console.log(a);
Share
Improve this question
edited May 24, 2018 at 4:44
Ramesh Rajendran
asked May 24, 2018 at 4:42
Ramesh RajendranRamesh Rajendran
38.7k49 gold badges159 silver badges239 bronze badges
4
-
a.removeAt(a, 2);
? – DirtyBit Commented May 24, 2018 at 4:43 - @user5173426 That's also not working and getting the same error. – Ramesh Rajendran Commented May 24, 2018 at 4:43
- Yeah, I know how can i do delete. but my question is that document is correct or not? – Ramesh Rajendran Commented May 24, 2018 at 4:50
- 1 the documentation is an out of date reference to a jscript (not javascript) function. – Claies Commented May 24, 2018 at 4:51
2 Answers
Reset to default 7There is no Array.removeAt()
function in JavaScript.
MSDN article is an out of date reference to a JScript (not JavaScript) function.
Alternatively you can use Array.splice()
or some other similar functions.
For more information check here: https://developer.mozilla/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
public static void Main()
{
char[] a = new char[] { 'a', 'b', 'c', 'd', 'e'};
string str = new string(a);
int index = str.IndexOf('a');
str=str.Remove(index,1);
a = str.ToCharArray();
Console.WriteLine(a);
}
OUTPUT:
bcde
DEMO:
dotNetFiddle
本文标签: javascriptquotUncaught TypeError ArrayremoveAt() is not a functionquot Stack Overflow
版权声明:本文标题:javascript - "Uncaught TypeError: Array.removeAt() is not a function", - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743883250a2555585.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论