Chrome generated the error Uncaught TypeError: Cannot read property 'length' of undefined when creating an object for the SuperArray class.Since SuperArray inherits Array, I thought I could use the length parameter...
By the way, you can list.length to SuperArray object list, but list.unnest().length will cause the above error.
I studied inheritance and protocol, but there are many things I don't understand.It seems that there are many things that I misunderstood, but it would be very helpful if you could tell me.Thank you for your cooperation.
Additional information below
_delegate and constructor are marked as jsweet.I don't really want to throw a whole ball, but there are many things I don't understand even if I look into it, so I would appreciate it if you could tell me about a website that I can refer to.
SuperArray has not succeeded to Array
I think it's going to work in
When inheriting complex built-in objects such as Array and RegExp, it is preferable to inherit using the
extends keyword rather than using the
Object.create to inherit them.
Array features that manipulate index properties when manipulating length properties are also inherited
If the environment is not available after ES6, I think it would be better to convert it to ES5 in Babel.
There is also an online repl, so why don't you try it?
© 2022 OneMinuteCode. All rights reserved.