Search

Javascript - 取得物件長度

2014-11-16 3:20 PM
程式碼範例
var obj = {
 "key1": value1,
 "key2": value2,
 "key3": value3
};

var length = Object.keys(obj).length;

console.log(length);

//結果為
3

No comments:

Post a Comment