Javascript doesn't have a general object iterator, to allow something like:
foo.iterate (function (key, value) {
console.log ("key->" + key + " value->" + value);
});
Seems convenient and trivial to implement. Is something like this built in to any popular libraries? I don't want to reinvent the wheel, and if do something like this would like to follow naming (and semantic) conventions for any existing method.
So does a general iterator like this exist somewhere?
added: I've been tinkering around and added an iterator function to Object.prototype. This slowed down the for loop by a factor of about 20! I wasn't even calling the new iterator method, just adding it to Object's prototype greatly slowed down for loops. I'm assuming this negates an optimization in Chrome. This would explain why none of these libraries mentioned add an iteration method to Object.