No constructor call for anonymous class

We can of course do:

class Person
        constructor: (firstName, lastName) ->
            this.firstName = firstName;
            this.lastName = lastName;

        name: ->
            "#{this.first_name} #{this.last_name}"

        setName: (name) ->
            names = name.split " "

            this.firstName = names[0]
            this.lastName = names[1]
new Person "Alice" "Fort"

But we can’t do:

new class
        constructor: (firstName, lastName) ->
            this.firstName = firstName;
            this.lastName = lastName;

        name: ->
            "#{this.first_name} #{this.last_name}"

        setName: (name) ->
            names = name.split " "

            this.firstName = names[0]
            this.lastName = names[1]
"Alice" "Fort"

Any possible workaround?

1 possible answer(s) on “No constructor call for anonymous class