最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin7PV0评论

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
Add a ment  | 

2 Answers 2

Reset to default 7

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/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

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far