Factory functions
New keyword
- creates a new object
- sets the this context to the new object
- good examples at https://stackoverflow.com/
questions/1646698/what-is-the- new-keyword-in-javascript
Factory function
- any function that returns a new object (just done manually)
createUser : function(username) {
return {
name: username
}
}
Comments
Post a Comment