JS for Data common operations

Source: Internet
Author: User

var _mozi=[' mohist ', ' Mozi ', ' Modi ', ' and love non-offensive ', ' still with Shangxian '];

$.each (_mozi,function (key,val) {//First key after value loop

Console.log (Key+val);

})

var Mozig = $.grep (_mozi,function (Val,key) {//filter array first value, post key

Return key<=1;

})

Console.log ("-----------------");

Console.log (Mozig);

var _maparra=$.map (_mozi,function (val) {//convert array by given condition [general]

return return val+ ' [New plus] '; After each element add \ ' [New plus]\ ' character to the array as

Return val== ' Mozi '?  ' [only for Meziga] ' +val:val; Only after adding characters to the element Mozi

return [Val, (val+ ' [Extended] ')];//for each element in the original array, extending an added character \ ' [New plus]\ ' element

});

Console.log ("-----------------");

Console.log (_maparra);

var _exist=$.inarray (' Still with Shangxian ', _mozi);//Determine if the value exists in the array

Console.log (_exist);

$.merge (First,second) merging of two arrays [general]

var _mozi2 = ["Chinese", "Wei People", "AFFF", "fffff", "Wei People"];

var _merge = $.merge (_MOZI,_MOZI2);

Console.log ("++++++++++++++");

Console.log (_merge);

$.unique (array) filters repeating elements in an array

Console.log ("000000000000000000");

Console.log (_MOZI2);

Console.log ($.unique (_MOZI2));

Join is to convert an array to a string by joining the parameters of the join.

var pstring = _mozi2.join ("+");

Console.log (_mozi2.join (""));

var obj2 = pstring.split ("+");

Console.log (OBJ2);

JS for Data common operations

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.