Practical Methods in ember. js and practical methods in ember. js

Source: Internet
Author: User

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 ('-----------------------------------------------');

  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.