Skip to content

Instantly share code, notes, and snippets.

@bmavity
Created February 4, 2011 22:24
Show Gist options
  • Save bmavity/811895 to your computer and use it in GitHub Desktop.
Save bmavity/811895 to your computer and use it in GitHub Desktop.
Object iteration
// Implementation
var iter = function(obj, callback) {
Object.keys(obj).forEach(function(key) {
callback(key, obj[key]);
});
};
// Usage
iter(obj, function(name, val) {
// Do shit here
});
// Even better
obj.iter(function(name, val) {
// Do shit here
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment