Not all objects are used as maps, and when using with map we often use `Object.create(null)`, so adding to prototype is definitely a bad idea. As for whether we should make them static methods of Object, I personally don't think this is very useful. Using a for-in loop is enough in my opinion.
From: [email protected] Date: Fri, 29 Jan 2016 18:07:30 -0500 Subject: Additional methods for Objects (like Arrays) To: [email protected] I have recently come to feel the need for Object.map, which is like Array.map, except that it receive keys instead of indices. Object.prototype.map = function(mapFn, context) { return Object.keys(this) .reduce(function(result, key) { result[key] = mapFn.call(context, this[key], key, this); return result; }, {});}; Without this, I frequently do the exact same thing as the above manually,which leads to unnecessary code duplication. Given that, it might make sense to match other methods from Array.prototype Object.mapObject.filterObject.everyObject.someObject.reduceObject.findObject.findKey // like Array.findIndex Note that wherever applicable, the ordering is non-deterministic. _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

