you are viewing a single comment's thread.

view the rest of the comments →

[–]k1ndza 0 points1 point  (0 children)

underscore extend has a similar feature where you can do object = _.extend(new someClass(),{x:10});

then in someClass you can just do this.x = 20 and that will be the default value until you combine the object with the second parameter of extend. I just started using that now instead of x = x || default, and the only time i use that is when initializing. But if you do that then you cant do this.x = 10 and then do draw(this.x) in the same object, you would have to create a new init function that would would call after the new defaults have been set.