In the CoffeeScript program below, I create a subclass of Array
which sets two positions in its constructor:
class SetPositionsArray extends Arr
Array.length is a special property that doesn't work when subclassed.
If you look at the compiled javascript for your first example the way CoffeeScript builds classes is by creating a function and calling __extends(SetPositionsArray, Array);
. This method can't 'copy' the concept of length into your new class.