Js键值对类型

声明:

var points= {};

 

存:

points.a='123'; 
points.b ='456';
var p1 = 'c';
points[p1]='789';

结果points= {'a':'123','b':'456','c':'789'};

 

 

取:

var d = points['a']; 
//则d的值就是‘123’

 

删除:

delete(points['a']);

 

循环取值:

for(var i in points)
{
    alert(points[i]);
}

 

posted @ 2022-02-18 15:50  朱小勇  阅读(144)  评论(0编辑  收藏  举报