Practical Methods in ember. js and practical methods in ember. js
A jQuery-based plug-in. The following are some methods about arrays.
var arr = ['Wang', 'Jason', '444128852@qq.com', 'i2cao.xyz', 'ubuntuvim.xyz'];arr.forEach(function(item, index) { console.log(index+1 + ", " +item);});
// Obtain the header and tail elements and directly call the firstObject and lastObject Methods encapsulated by Ember to console. log ('the firstItem is '+ arr. get ('firstobject'); // output> chenconsole. log ('the lastItem is '+ arr. get ('lastobject'); // output> ubuntuvim. xyz
// Map Method: converts an array. You can add your own logic in the callback function. // The map method creates an array and returns the element var arrMap = arr. map (function (item) {return 'map: '+ item; // Add your own required logical processing}); arrMap. forEach (function (item, index) {console. log (item) ;}); console. log ('-----------------------------------------------');
// MapBy method: returns the set of Object Attributes. // when your array element is an object, you can obtain the corresponding value var obj1 = Ember Based on the object attribute name. object. create ({username: '000000', 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]; // object array var tmp = arrObj. mapBy ('username'); // tmp. forEach (function (item, index) {console. log (index + 1 + "," + item) ;}); console. log ('-----------------------------------------------');