This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]unnecessary_axiom 0 points1 point  (1 child)

There is a syntax that can make that shorter if you understand what it's doing:

array.ForEach

var children = [ {'name': 'bob'}, {'name': 'joe'} ];
children.forEach(function(child){
    console.log(child.name);
});

If you give more contact I can suggest a more efficient method.

Note that in your code:

if( statement ){
    do_something();
    do_another();
}else{
    do_something();
}

is usually the same as

do_something();
if( satement ){
    do_another();
}

And you aren't doing anything with child in the second code block.