substring and substr String Methods
Video
JavaScript Notes
JavaScript
// substring and substr String methods
// str.substring(from, to)
// str.substr(from, length)
let str = "Nobody calls me Lebowski you got the wrong guy I’m the Dude, man.";
let log = console.log;
log(str.substring(16, 24); // returns “Lebowski”
log(str.substring(16); // returns “Lebowski….to end of string”
log(str.substr(16, 0); // returns nothing
log(str.substr(16, 9); // returns “Lebowski”
log(str.substr(-16, 9); // returns “m the Dud” (negative means start at end of string and move backwards)
Feedback
Submit and view feedback