On type checking
More on type checking in JavaScript
(See also the "Comparison and inspiration" section for other JS type checking libraries.)
On "duck typing"
- From Wikipedia > Duck typing:
- "duck typing is a style of dynamic typing in which an object's current set of methods and properties determines the valid semantics, rather than its inheritance from a particular class."
- In the criticism section:
- "duck typing [...] forces the programmer to have a much wider understanding of the code"
- "you could easily create a class called Wine, which expects a class implementing the "press" attribute as an ingredient. However, a class called Trousers might also implement the press() method"
- From http://blog.michaeleee.com/2008/02/javascript-interfaces-and-duck-typing.html
- "In summary, duck typing keeps things simple but requires you to trust your development team to keep track of all the details. Duck typing is popular among the Ruby community. As one moves from a small team to larger projects involving separate subgroups, you can not rely on this trust, and you may want to add a few checks and balances to your code on top of duck typing."
- http://www.sitepen.com/blog/2007/10/14/dealing-with-the-flexibility-of-javascript/
Best practices
Similar libraries in other dynamic languages
See also the "Comparison and inspiration" section, for other JavaScript code doing type checking.