In this quick tip, you’ll see how to remove first character from string in jQuery and JavaScript. You can achieve this using slice and substring method.

Solution Using Slice Method

Here is a solution to remove first character from string using slice method.

let input = "codehandbook"

function removeCharacter(str){
  let tmp = str.split('');
  return tmp.slice(1).join('');
}

let output = removeCharacter(input);
console.log(`Output is ${output}`);

slice method slices the array from the start index to end index. end index if unspecified is taken as array length.

Solution Using Substring Method

You can also remove the first character from a string using substring method.

let input = "codehandbook"

function removeCharacter(str){
  return str.substring(1)
}

let output = removeCharacter(input);
console.log(`Output is ${output}`);

substring method returns string between start index and end index. end index if unspecified is assumed as string length, as in this case.