Closed ronen-e closed 3 years ago
I don't believe your solution is correct. There's no reason to reference ES5 here. The goal of the example is to show that slice()
automatically returns an instance of MyArray
without any other changes. I agree the last sentence could use some tweaking. Maybe something like:
However, the constructor for the return value is read from the
Symbol.species
property, allowing for this change.
Where In chapter 9 - Classes under section The Symbol.species Property. see line 835
Problem
Reason The example is meant to show the behavior of the
Symbol.species
property. In it theslice()
method returns an instance ofMyArray
; not just a regular instance ofArray
as we would normally expect in ES5Solution change the wording to something like: