all the time since I widely use private methods and I reuse them per each
created instance of a specific "class"
The boundTo() approach would make the method still private, immutable out
there, and reusable per each instance/object I need.
// stupid useless example ... just as concept
var Counter = (function () {
// private
function increase() {
this.age++;
}
function Counter() {
// none out there should be able to retrieve the bound function
document.addEventListener("click", this.boundTo(increase), false);
};
Counter.prototype.age = 0;
Counter.prototype.destroy = function () {
// so that only this class scope can control things and nobody else
document.removeEventListener("click", this.boundTo(increase), false);
};
return Counter;
}());
Last, but not least, I do duck typing and I often borrow methods around for
smaller common tasks
Best Regards,
Andrea Giammarchi
On Thu, Jan 5, 2012 at 5:11 PM, Axel Rauschmayer <[email protected]> wrote:
> that would not solve much 'cause you can bind a function to a single
> object and no more.
>
>
> Isn’t that the most frequent use case? Do you have examples where you bind
> the same function to several objects?
>
> --
> Dr. Axel Rauschmayer
> [email protected]
>
> home: rauschma.de
> twitter: twitter.com/rauschma
> blog: 2ality.com
>
>
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss