The slice() method extracts parts of a string and returns the extracted parts in a new string. slice() extracts up to but not including endSlice. str.slice(1, 4) extracts the second character through the fourth character (characters indexed 1, 2, and 3).
var str = 'MyTestingString';
console.log(str.slice(2,8)); // Testin
The substr() method returns the characters in a string beginning at the specified location through the specified number of characters.
The substring() method returns a subset of a string between one index and another, or through the end of the string (similar to slice method).
Ввійдіть щоб вподобати
Ввійдіть щоб прокоментувати