问题描述:

I would like to get length of the array in this object:

obj = {'2012-08-08':[1,2,5,8]}

I understand we can get length like this:

obj['2012-08-08'].length

But if it is not known the name of the key how we get the length of the array?

Say I have a loop:

_.each(dates, function(date){

//each date is like the above javascript object, how to get the length of the array?

})

网友答案:

You have a date parameter in your call to each. Just call date.length.

相关阅读:
Top