Private members in CoffeeScript?

后端 未结 11 2062
太阳男子
太阳男子 2020-12-12 13:37

Does somebody know how to make private, non-static members in CoffeeScript? Currently I\'m doing this, which just uses a public variable starting with an underscore to clari

11条回答
  •  旧时难觅i
    2020-12-12 14:10

    Is it even possible without getting "fancy"?

    Sad to say, you'd have to be fancy.

    class Thing extends EventEmitter
      constructor: (name) ->
        @getName = -> name
    

    Remember, "It's just JavaScript."

提交回复
热议问题