Method Chaining 1

Method Chaining

String methods can be combined in a process called method chaining. 
Given word = 'JavaScript';, word.toUpperCase() returns JAVASCRIPT. 
What would word.slice(4).toUpperCase() return?

Here is what the above code is Doing:
1. word.slice(4) returns the string ‘Script’.
2. ‘Script’.toUpperCase() returns the string ‘SCRIPT’.
3. word.slice(4).toUpperCase() returns the string ‘SCRIPT’.

Similar Posts