KO - Constructor Hash - 2

KO - Constructor Hash - Non automatic assignment

by patelsan

HTML

<script src="https://github.com/downloads/SteveSanderson/knockout/knockout-2.1.0rc2.js"></script>

CoffeeScript

class Person
 @firstName: ko.observable()
 @lastName: ko.observable()
 
 constructor: (params = {})->
  @firstName = ko.observable(params['firstName'])
  @lastName = ko.observable(params['lastName'])
  
 print: ()->
  console.log @firstName() + ' ' + @lastName()

window.jack = new Person({firstName: 'Jack', lastName: 'Smith'})     
console.log window.jack.firstName()
console.log window.jack.lastName()
window.jack.print()