The array methods in the ECMA Script5 such as indexof (), ForEach (), map (), filter (), some () do not support ie6~8, but there is still a large majority of users in the country using Ie6~8, and the above array method is really useful. In the past,
The following small series will introduce you to the array traversal forEach () and map () methods in JavaScript and the compatible writing method. I think it is quite good. Now I will share it with you and give you a reference. Let's take a look at
1. js array looping. Array loop variables, the first thought of is the for (vari0; I & lt; count; I ++) method. In addition, you can also use the relatively simple forEach method 2. forEach function. The Array types of Firefox and Chrome both have
Note: Original address http://blog.csdn.net/oscar999/article/details/8671546I am here to imitate the study!1, the array of JS loop traversalThe traversal of the ① array is the first thought of the for () Loop statementvar arr = [' Summer ', ' I ', '
1. js Array loop traversal.Array loop variables, the first thing to think about is the for (Var i=0;iIn addition, a simpler foreach method can be used2. The ForEach function.Both Firefox and Chrome's array types have a foreach function. Use the
1.js Array loop traversal.
Array loop variable, the first thing to think about is the for (Var i=0;i
In addition, you can use a simpler foreach method
2.forEach function.
Both Firefox and Chrome's array types have foreach functions. Use the
1. js Array loop traversal.Array loop variables, the first thing to think about is the for (Var i=0;iBoth Firefox and Chrome's array types have a foreach function. Use the following: New Document &L t;/title> But the above, the code in IE
1. js Array loop traversal. array loop variable, the first thing to think about is the for (Var i=0;i
In addition, you can use a simpler foreach method
2. The ForEach function.Both Firefox and Chrome's array types have foreach functions. Use the
Array functions(both index and ARR in the callback function here can be omitted, the callback function has parameters that are set to adjust this point, which is not used here for the time being)
ForEach ()
Map ()--Update array
Translator by: I love the map more than Haskell.
Original: JavaScript?—? Map vs. Foreach-what ' s The difference between Map and ForEach in JavaScript?
Translator: Fundebug
In order to ensure readability, this paper uses free
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.