Two useful string functions - substr & substring | ||
| ||
| Now a days, javascript is widely used for web 2.0 programming. Syntax: string.substr(start, length); Quick Notes aout Substr: If start is negative, Internet Explorer returns the whole string. That’s wrong! IE should use the last character in the string.
Syntax: string.substring(start, stop);
If start equals stop, it returns an empty string. If stop is omitted, it extracts characters to the end of the string. If either argument is less than 0 or is NaN, it is treated as if it were 0. If either argument is greater than string’s length, either argument will use string’s length. If start > stop, then substring will swap those 2 arguments. | ||
| | ||
| |