Languages
[Edit]
EN

JavaScript - remove character from string at specific index

0 points
Created by:
a_horse
538

In this article, we would like to show you how to remove a character from a string at a specific index in JavaScript.

Quick solution:

Note:

This approach doesn't remove the original string, it makes a copy ignoring the given character and overwriting the text.

 

Reusable function

Edit

In this example, we create a reusable function that takes 2 arguments:

  1. text - the string we want to remove a character from,
  2. index - the index we want to remove.

Output:

References

Edit
  1. String.prototype.substring() - JavaScript | MDN

Alternative titles

  1. JavaScript - remove character from text at specified position
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join