Skip to content

Instantly share code, notes, and snippets.

@corpix
Created May 23, 2012 21:25
Show Gist options
  • Save corpix/2777927 to your computer and use it in GitHub Desktop.
Save corpix/2777927 to your computer and use it in GitHub Desktop.
for,forEach loops example
var obj, key, arr;
obj = {
foo: 'bar',
baz: 'faz'
};
for(key in obj){
console.log(key, ':', obj[key]);
}
arr = [
'foo',
'bar'
];
arr.forEach(function(value, key){
console.log('arr[%s] = %s', key, value);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment