Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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);
like image 407
Ramesh Rajendran Avatar asked Mar 28 '26 21:03

Ramesh Rajendran


1 Answers

There 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.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice

like image 58
Vikasdeep Singh Avatar answered Mar 31 '26 03:03

Vikasdeep Singh