From closures to prototypes, part 2
Posted by: More Whidbey stuff,
on 14 Oct 2006 |
View original | Bookmarked: 0 time(s)
In part 1 of this post, I exposed the differences between the closure and the prototype patterns to define JavaScript classes. In this post, I'll show the shortest path to convert an existing class built using Atlas and closures to a prototype-based class. I'll also show a few caveats that you need to be aware of.Here's an example of a class built using the July CTP of Atlas:Custom.Color = function(r, g, b) {
Custom.Color.initializeBase(this);
var _r = r || 0;
var _g = g || 0;
...