Don't use for-in to iterate array entries.
Rick
On Friday, August 23, 2013, Александр Крылов wrote:
> Hello!
> I have problem.
>
> For test example code:
>
> var user = {}
> var action = 'test';
>
> user[action] = [{ user_id: '521319f2df3b320810000005',
> _id: '521723678857785c0500000b',
> action: { acType: 'photo', acId: '3' },
> viewed: false },
> { user_id: '521319f2df3b320810000005',
> _id: '5217293a1cab19bc11000008',
> action: { acType: 'photo', acId: '1' },
> viewed: false },
> { user_id: '521319f2df3b320810000005',
> _id: '52172c97d8b04bdc11000008',
> action: { acType: 'photo', acId: '1' },
> viewed: false },
> { user_id: '521319f2df3b320810000005',
> _id: '52172cc201feeff811000008',
> action: { acType: 'photo', acId: '1' },
> viewed: false },
> { user_id: '521319f2df3b320810000005',
> _id: '52172ce901feeff811000009',
> action: { acType: 'photo', acId: '1' },
> viewed: false },
> { user_id: '521319f2df3b320810000005',
> _id: '52172d0d80f9c07013000008',
> action: { acType: 'photo', acId: '1' },
> viewed: false },
> { user_id: '521319f2df3b320810000005',
> _id: '52172e038c017e0412000008',
> action: { acType: 'photo', acId: '1' },
> viewed: false },
> { user_id: '521319f2df3b320810000005',
> _id: '52172e8ca282584010000008',
> action: { acType: 'photo', acId: '1' },
> viewed: false }];
> console.log(user[action]);
> for(var i in user[action]){
> console.log(i);
> }
>
> So, first console.log shows all elemrnts of array, good. Second
> console.log shows key of iteration and shows:
>
> 0
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> _atomics
> validators
> _path
> _parent
> _schema
> _cast
> id
> toObject
> inspect
> create
> notify
> _markModified
> _registerAtomic
> $__getAtomics
> hasAtomics
> push
> nonAtomicPush
> $pop
> pop
> $shift
> shift
> pull
> remove
> splice
> unshift
> sort
> addToSet
> set
> indexOf
>
> I tested in Node.js (0.10.12) and all browsers. Problem only in node.js
> Can you help me?
>
> --
> --
> 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]<javascript:_e({}, 'cvml', '[email protected]');>
> To unsubscribe from this group, send email to
> [email protected] <javascript:_e({}, 'cvml',
> 'nodejs%[email protected]');>
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected] <javascript:_e({}, 'cvml',
> 'nodejs%[email protected]');>.
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
--
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
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.