Joined February 2017
·

Romaboy

Posted to Subclassing JavaScript's Array class over 1 year ago

Hello, your post helped me, but I want to suggest improvement:


class ArrayWrapper extends Array

  method: -> console.log 'hello'

new ArrayWrapper().method() # This doesn't work!

It is can't be called "class" without methods, so:


class ArrayWrapper

proto = ArrayWrapper.prototype = Object.create Array.prototype

proto.method = -> console.log 'hello' # Yes, we are loosing simple methods notations

new ArrayWrapper().method() # great!

Markdown in this site infuriates me

Achievements
1 Karma
0 Total ProTip Views