Uh, well, you've overridden the ability to accept a first and last name in the constructor. So I'm guessing you want to accept the base classes constructor arguments as well as additional arguments?
Something like this could work with any number of arguments from the base class constructor.
class Person
constructor: (@firstName, @lastName) ->
sayName: ->
console.log "Hi, im #{@firstName} #{@lastName}"
class Employee extends Person
constructor: (args..., @position) -> super
dude = new Employee 'Shooty', 'McFace', 1
dude.sayName() # Hi, im Shooty McFace
console.log "position: #{ dude.position }" # position: 1
Here we use a splat (the ...
) to soak up any arguments that we don't need to name. All these arguments get implicitly passed to super
which is the base class constructor. The last argument will be the additional argument you want to capture.