Please keep in mind that getting the "size" of an object like this is NOT a
constant time operation, as it would be with an array.  If you are using
the size frequently you should consider keeping a separate variable with
the length yourself, instead of doing Object.keys(table).length every time.

You can iterate over the table with:
for (var key in table) {
  console.log(key, table[key]);
}

On Sat, Jun 16, 2012 at 12:05 PM, Mark Hahn <[email protected]> wrote:

> I highly recommend using underscore.  _.size and _.keys will get you what
> you want.
>
>
> On Sat, Jun 16, 2012 at 9:41 AM, dolphin 278 <[email protected]> wrote:
>
>> You can use Object.keys("yourobjectvariable") to get array of object
>> fields.
>> In your example Object.keys("yourobjectvariable").length will be 2.
>> ---------
>> Boris Egorov
>> skype/gtalk/nickname: dolphin278
>> mobile: +7 905 728 1543
>>
>>
>>
>> On Sat, Jun 16, 2012 at 8:25 PM, vitoa <[email protected]> wrote:
>>
>>> Tanks a lot for the Object sugestion that works great :)
>>> One more question.
>>> How can I list all indexs in this object or the size, are there any
>>> methods?
>>>
>>> for example I have
>>> table
>>> { xxx: [ 'xxx', 'aaa', '123' ], zzz: [ 'zzz', 'aaa', '123333' ] }
>>>
>>> How can I have the length of this table(should be 2) and show all
>>> indexs available
>>> I found that I only can acess the data if I have index name like
>>> table['xxx']
>>>
>>> Regards,
>>> Vitor
>>>
>>> --
>>> Job Board: http://jobs.nodejs.org/
>>> Posting guidelines:
>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>> You received this message because you are subscribed to the Google
>>> Groups "nodejs" group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>
>>
>>  --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>
>  --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to