Dependency issue in inheritance chain

Posted by Razer on Stack Overflow See other posts from Stack Overflow or by Razer
Published on 2014-08-24T16:17:09Z Indexed on 2014/08/24 16:19 UTC
Read the original article Hit count: 236

Filed under:
|

I have a class in coffeescript a class layout like the following.

class @A
  foo: ->
    console.log('foo')

class @B extends A
  fooB: ->
      @foo()

class @C extends B
  fooC: ->
      @foo()  

I tried this in interpreters, it works. However it raises errors, when executing this in the browser (all of them are in separate coffee files, and are used in a global context. Therefore the @ before the class):

Uncaught ReferenceError: B is not defined application.js

It seems that B is defined after the definition of C. How can this happen?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about coffeescript