Languages
[Edit]
EN

JavaScript - remove first character from string

8 points
Created by:
Root-ssh
68690

In JavaScript it is possible to remove first character from string in following ways.

1. Using String slice() method

// ONLINE-RUNNER:browser;

var text = "abc";
var substring = text.slice(1);

console.log(substring); // bc

2. Using String substring() method

// ONLINE-RUNNER:browser;

var text = "abc";
var substring = text.substr(1);

console.log(substring); // bc

3. Using String replace() method

// ONLINE-RUNNER:browser;

var text = "abc";
var substring = text.replace("abc", "bc");

console.log(substring); // bc

Merged questions

  1. JavaScript - how to chop off first char from string?
  2. How do I trim off first char in JavaScript?
  3. JavaScript - delete first character of string
  4. Slice off first character in js
Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join