Home > Web Front-end > JS Tutorial > js Map List traversal usage example_javascript skills

js Map List traversal usage example_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 17:29:19
Original
1807 people have browsed it

Map (exMap:{"name":"abc","sex",'male'}):
Traverse the map without knowing the key:
This method has been said on the Internet:

Copy code The code is as follows:

for(var key in exMap){
Console.write(" key:" key ";value:" exMap[key]);//After my research, the key is undefined.So the method is not right.
}

Another method (Good):
Copy code The code is as follows:

$.each(exMap,function( key, value){
Console.wiite("key:" key ";value:" value);
});

It is natural to traverse the map when knowing the key Just like accessing arrays, we won’t go into details here.
List access is very simple:
Copy code The code is as follows:

for(var i =0;ivalue = list[i]
}

Reference (jquery filtering array grep, each, inArray, map usage and Traversing json objects):
http://sjolzy.cn/jquery-selection-and-use-of-an-array-of-grepeachinArraymap-json-object-traversal.html
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Where is js written?
From 1970-01-01 08:00:00
0
0
0
js addClass not working
From 1970-01-01 08:00:00
0
0
0
js file code not found
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template