JavaScript Replace first character of string
JavaScript Replace first character of string
The indexOf() method returns the position of the first occurrence of a specified value in a string.This method returns -1 if the value to search for never occurs.
var string = '|0|0|0|0';
str.indexOf( '|' ) == 0 ? str = str.replace( '|', '' ) : str;
Related Posts
Javascript Shorthand If Else, JavaScript Methods Available in the Array Object,Regular expression, new RegExp - Javascript