On Mar 21, 2011, at 1:13 PM, Erik Arvidsson wrote:
> {
> extend Object.prototype with {
> filter: function(fun) {
> var retval = {};
> for (var key in this) {
> if (fun(this[key])
> retval[key] = this[key];
> }
> return retval;
> }
> };
>
> function largerThanN(obj, n) {
> return obj.filter(function(item) {
> return item > n;
> }
> }
>
> var a = [0, 1, 2, 3, 4];
> print(largerThanN(a, 2));
> var o = {a: 0, b: 1, c: 2, d: 3, e: 4};
> print(largerThanN(0, 2));
> }
I like it!
Just a reaction in brief. More this week at the meeting, I'm sure ;-).
> The above use case cannot be solved using private names because
> private names conflict with public names.
I don't see this, though. Don't oversell!
> Can we agree that this is a use case that we care about and focus on
> this instead of whether private names can or cannot do this?
Yes.
/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss