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