Courses / JavaScript
67. String.prototype.slice()
Extracts a section of a string and returns it as a new string, without modifying the original string.
1 min read Chapter 67 of 99
JavaScript
String.prototype.slice()
String.prototype.slice() extracts a portion of a string without altering the original.
"I need to get a substring without messing up the original string."
String.prototype.slice() takes two arguments, the start and end indices, and returns a new string containing the characters from the original string between those indices.
"I need to get a substring without messing up the original string."
String.prototype.slice() takes two arguments, the start and end indices, and returns a new string containing the characters from the original string between those indices.