Last Updated: February 25, 2016
·
1.193K
· sukima

Assigning a CoffeeScript class to a property

Did you know you can assign a class to a property or variable in CoffeeScript?

MyObject =
  property1: "value1"
  property2: class
    constructor: (@instance_var) ->
    instance_fn: ->

test_var = new MyObject.property2()

2 Responses
Add your response

Never thought about it, but now it seems logical ;-)

over 1 year ago ·

Why you would want to instantiate a whole new object class on the inside of a singleton I have no idea...

over 1 year ago ·