javascript - CoffeeScript, prototypal inheritance, and constructors -
in coffeescript, seems superclasses constructor not called when instantiate subclass.
is there way around this?
here example:
class element = null constructor: -> element = document.createelement "div" hide: => element.style.display = "none" class b extends constructor: -> @hide() #error!
i expect constructor of a
called first, b
's constructor. if b
calls hide
method, should hide element created in a
's constructor instead of saying element
null.
thanks!
i think need phone call super in subclass
class element = null constructor: -> element = document.createelement "div" hide: => element.style.display = "none" class b extends constructor: -> super @hide() #error!
javascript constructor coffeescript prototype
No comments:
Post a Comment