Question · JavaScript and TypeScript course · Module 2: Functions, Arrays and Objects
slice() Method - Negative Index
What will 'Tyrannosaurus Rex'.slice(-3) return?
Answer options
- 'Tyr' - first 3 characters
- 'Rex' - last 3 characters
- 'us ' - 3 characters from the end, from the left
- undefined - negative index is not allowed
Show the answer
Correct answer:
- 'Rex' - last 3 characters