Home > Web Front-end > JS Tutorial > body text

Example of how to use an associative array to create an array with javascript_Basic knowledge

WBOY
Release: 2016-05-16 17:06:54
Original
1095 people have browsed it

Copy code The code is as follows:

//Arrays in js can be key-value pairs The way exists
var arr = new Array();
arr["A"] = "boss";
arr["B"] = "Emp";
for (var m in arr ) {
            document.write(arr[m] " ");
                                                                                                                                                                                                                                                                 . ["age"] = "18";
person["salary"] = "1888.9";
for (var p in person) {
document.write(person[p] " }
//Does the test use the age attribute?
                                                                                                                                                                                                                                                                                                   .
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template