星空网 > 软件开发 > Java

ember.js里的实用方法

一款基于jQuery的插件,以下是关于数组的一些方法

var arr = ['Wang', 'Jason', '444128852@qq.com', 'i2cao.xyz', 'ubuntuvim.xyz'];arr.forEach(function(item, index) { console.log(index+1 + ", " +item);});

  

// 获取头尾的元素,直接调用Ember封装好的firstObject和lastObject方法即可console.log('The firstItem is ' + arr.get('firstObject')); // output> chenconsole.log('The lastItem is ' + arr.get('lastObject')); //output> ubuntuvim.xyz

  

// map方法,转换数组,并且可以在回调函数里添加自己的逻辑// map方**新建一个数组,并且返回被转换数组的元素var arrMap = arr.map(function(item) { return 'map: ' + item; // 增加自己的所需要的逻辑处理});arrMap.forEach(function(item, index) { console.log(item);});console.log('-----------------------------------------------');

  

// mapBy 方法:返回对象属性的集合,// 当你的数组元素是一个对象的时候,你可以根据对象的属性名获取对应值var obj1 = Ember.Object.create({ username: '123', age: 25}); var obj2 = Ember.Object.create({ username: 'name', age: 35});var obj3 = Ember.Object.create({ username: 'user', age: 40}); var obj4 = Ember.Object.create({ age: 40}); var arrObj = [obj1, obj2, obj3, obj4]; //对象数组var tmp = arrObj.mapBy('username'); // tmp.forEach(function(item, index) { console.log(index+1+", "+item);}); console.log('-----------------------------------------------');

  




原标题:ember.js里的实用方法

关键词:JS

JS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

Bloomingdale's 布鲁明黛 :https://www.goluckyvip.com/tag/16532.html
bloomingltd:https://www.goluckyvip.com/tag/16533.html
Bloomscape:https://www.goluckyvip.com/tag/16534.html
BLS Int'l:https://www.goluckyvip.com/tag/16535.html
Blue Apron:https://www.goluckyvip.com/tag/16536.html
Blue Nile:https://www.goluckyvip.com/tag/16538.html
DTC个护品牌Svish Ropes完成新一轮融资:https://www.kjdsnews.com/a/1842223.html
五一节三亚、南山寺,海棠湾,海角天崖的门票各是多少,我是外地人?:https://www.vstour.cn/a/409234.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流