在 JavaScript 中创建一个关联数组

Create an associative array in JavaScript

本文关键字:一个 关联 数组 JavaScript 创建      更新时间:2023-09-26

考虑:

var playlist = {"bad romance":"gaga", "we cry":"the script"};

如何从我的代码中获取字符串"gaga"?我的数组在 JavaScript 编程中叫什么名字?

尝试Object而不是Array

var playlist = {"bad romance":"gaga", "we cry":"the script"};
alert(playlist["bad romance"]); //gaga