Home >Web Front-end >JS Tutorial >Example of how to use an associative array to create an array with javascript_Basic knowledge

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

WBOY
WBOYOriginal
2016-05-16 17:06:541101browse

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?
                                                                                                                                                                                                                                                                                                   .
Statement:
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