ExtJS中是否有map()函数? [英] Is there a map() function in ExtJS?

查看:171
本文介绍了ExtJS中是否有map()函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ExtJS有Ext.each()函数,但是还有一个map()也隐藏在某个地方?



我已经尝试过,但没有找到任何可以填补这个角色。这似乎是一件简单而简单的事情,一个像Ext这样大的JS库必须有。



或者Ext真的不包括它,那会是什么最好的方法来添加到Ext。当然,我可以写:

  Ext.map = function(arr,f){...}; 

但这真的是正确的方法吗?

解决方案

看来,我这里的大学正在使用 ext-basex ,它使用map()和其他方法扩展了Array.prototype。



所以我可以写:

  [1,2,3] .map(function(){...}); 

问题解决。


ExtJS has Ext.each() function, but is there a map() also hidden somewhere?

I have tried hard, but haven't found anything that could fill this role. It seems to be something simple and trivial, that a JS library so large as Ext clearly must have.

Or when Ext really doesn't include it, what would be the best way to add it to Ext. Sure, I could just write:

Ext.map = function(arr, f) { ... };

But is this really the correct way to do this?

解决方案

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.

这篇关于ExtJS中是否有map()函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆