Friday, April 15, 2016

javascript array loop

var length = arr.length;
    element = null;
for (var i = 0; i < length; i++) {
  element = arr[i];
   

  // Do something with element i.
}


new_array.push(element);


object loop through

for (var property in object) {
    if (object.hasOwnProperty(property)) {
        // do stuff
    }
}

No comments: