Getting rid of your for `for-loops` in javascript.
var original = [1,2,3,4,5,6];
var i, newList = [];
for (i = 0; i < original.length; i++) {
newList.push(original[i] * 2);
}
var original = [1,2,3,4,5,6];
var newList = original.map(function(o){
return o * 2;
});
Iterating over an objects keys
var obj = {a: 1, b: 2, c: 3},
k, v;
for (k in obj) {
if (obj.hasOwnProperty(k)) {
v = obj[k];
// ...
}
}
var obj = {a: 1, b: 2, c: 3};
Object.keys(obj).map(function(k){
var v = obj[k];
// ...
});