New features of JavaScript arrays

Source: Internet
Author: User

1 <!DOCTYPE HTML>22<HTMLLang= "en">33<Head>44<MetaCharSet= "UTF-8">55<title>Test1</title>66<Script>7   7        8  94         9   the         /*Ten  the One Every,some The former is to iterate over each element in the array and execute the function, if there is a return of false then return false/the latter if there is a return true A 98 Filter,map The former to iterate through the elements in the array, which can be understood as filtering the elements and executing the function, returning the filtered array/the latter returning the new value after the function run calculation - the loop ForEach iterates through each element and executes a function that returns the array -  - the 101 - 102*/ - 103    - 135          + 136          - 137         vararr= [1,4,2,5,7,2]; + 138          A 139         varRESULT1=Arr.every (function(Item,index,array) { at  $             returnItem>4;//returns false - 141         }); - 142          - 143Console.log (RESULT1); - 144          - 145         varresult2=Arr.some (function(Item,index,array) { in 146             returnItem>1 - 147         }); to 148          + 149Console.log (RESULT2);//returns True -  Max          the 151          *  the         varArr_filter=Arr.filter (function(Item,index,array) { $ 153             returnItem< 5;Panax Notoginseng 154         }); - 155          the 156Console.log (arr_filter);//[1,4,2,2] + 157          A 158         varArr_map=Arr.map (function(Item,index,array) { the 159             returnItem>4; +  the         }); - 161          $ 162Console.log (arr_map);//[False, False, False, True, True, false] $ 163          - 164          - 165Arr.foreach (function(Item,index,array) { the 166Item=Item*3; - 167Console.log (item);//returns each element after an operationWuyi 168         }); the 169          -  the     </Script> Wu171</Head> -172<Body> About 173 $174</Body> -175</HTML>

New features of JavaScript arrays

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.