#UC8204
想问关于JavaScript的问题
var dic = {c:4, a:2, d:3, b:1}; // 定义一个å—å…¸
console.log(“输出最åˆçš„å—å…¸å…ƒç´ : “);
for(var key in dic){
console.log(“key: ” + key + ” ,value: ” + dic[key]);
}
console.log(“å—å…¸å…ƒç´ æŒ‰key值排åº: “);
var res = Object.keys(dic).sort();
for(var key in res){
console.log(“key: ” + res[key] + ” ,value: ” + dic[res[key]]);
}
console.log(“å—å…¸å…ƒç´ æŒ‰value值排åº: “);
var res2 = Object.keys(dic).sort(function(a,b){ return dic[a]-dic[b]; });
for(var key in res2){
console.log(“key: ” + res2[key] + ” ,value: ” + dic[res2[key]]);
}
console.log(dic[0,0])
请问for(var key in dic)是什么æ„æ€ï¼Ÿ
其实我想问的是这个è¯å…¸ä»£ç 究竟是如何实现的?