The substring() method also extracts parts:
let text = "JavaScript"
console.log(text.substring(0, 4)) // "Java"
console.log(text.substring(4, 0)) // "Java" (swaps if needed)
Unlike slice(), substring() treats negative numbers as and swaps arguments if start > end. Prefer slice() for its predictable behavior with negative indices.