学習者のアプローチ:
var myobj = {"1632":45,"1856":12,"1848":56,"1548":34,"1843":88,"1451":55,"4518":98,"1818":23,"3458":45,"1332":634,"4434":33};
// Get the keys of myobj so we can iterate through it
var keys = Object.keys(myobj);
// Iterate through all the key values
var minimumKey = keys[0];
for(var i = 1; i < keys.length; i++){
var minimum = myobj[minimumKey];
var value = myobj[keys[i]];
if(minimum > value) minimumKey = keys[i];
}
console.log(minimumKey, myobj[minimumKey]);
より機能的なアプローチ:言及用
var myobj = {"1632":45,"1856":12,"1848":56,"1548":34,"1843":88,"1451":55,"4518":98,"1818":23,"3458":45,"1332":634,"4434":33};
var minimum = Object.keys(myobj).map(function(key){
return {
"key": key,
"value": myobj[key]
}
}).sort(function(a, b){
return a.value - b.value
})[0];
console.log(minimum);
console.log(minimum.key);
console.log(minimum.value);
はい、申し訳ありません。答えを更新してください。 –