标签:
<script type="text/javascript">
var arr = new Array();
arr[‘cn‘] = ‘中国‘;
arr[‘usa‘] = ‘美国‘;
arr[‘jp‘] = ‘日本‘;
arr[‘kr‘] = ‘韩国‘;
for (var key in arr){
alert(key + ‘=‘ + arr[key]);
}
//[]表示数组,{}键值对
var arr1 = { ‘cn‘: "中国", ‘usa‘: ‘美国‘, ‘jp‘: ‘日本‘ };
for (var key in arr) {
alert(key + ‘=‘ + arr[key]);
}
}
var arr2 = [{ ‘name‘: ‘liky‘, ‘age‘: 15 }, { ‘name‘: ‘lucy‘, ‘age‘: ‘22‘ }];
for (var i = 0; i < arr.length; i++) {
alert(arr[i].name + ‘==‘ + arr[i].age);
}
var arr3 = { ‘name‘: ‘刘德华‘, ‘age‘: 19, ‘address‘: { ‘city‘: ‘beijin‘, ‘country‘: ‘China‘ } }
arr3.address.city;
</script>
标签:
原文地址:http://www.cnblogs.com/chao2014/p/4944584.html