Is There A Map() Function In Extjs?
Solution 1:
As of at least Ext4, Ext.Array.map is included.
http://docs.sencha.com/extjs/5.0.1/#!/api/Ext.Array-method-map
Solution 2:
Since map
is more of a utility than anything, I don't see why there would be any special way of plugging it into the Ext namespace; the way you propose would work well enough, though you might want to do it thusly:
if(Ext && typeof(Ext.map) == "undefined") { // only if Ext exists & map isn't already defined
Ext.map = function(arr, f) { ... };
}
Seems like that would be fine...but then, I don't use ExtJS, so I don't know. I did take a gander at their docs and it doesn't seem like there is anything special to do in this case.
Solution 3:
It appears, that my colleges here are using ext-basex, which extends Array.prototype with map() and other methods.
So I can just write:
[1, 2, 3].map( function(){ ... } );
Problem solved.
Solution 4:
What about using one of the hybrid libraries like Ext+Prototype or Ext+Jquery. I've been using Extjs+Prototypejs for a while now and it helped me a lot to work into the Extjs code with having the more familiar prototypejs along for the ride as well.
http://extjs.com/products/extjs/build/ will build a custom tar/zip file of all the files you need to run extjs and (prototypejs|jquery|yahooUI).
Solution 5:
ExtJS doesn't replace Javascript language itself. Array functions aren't in the focus of ExtJS core. However there is a special Ext.Array object type. You can extend it on your own.
EDIT: Not Ext.Array, but just extended Array object.
Post a Comment for "Is There A Map() Function In Extjs?"