Skip to content

Instantly share code, notes, and snippets.

@n8agrin
Created January 26, 2010 07:50
Show Gist options
  • Save n8agrin/286654 to your computer and use it in GitHub Desktop.
Save n8agrin/286654 to your computer and use it in GitHub Desktop.
safe eachIn method for object iteration in javascrip
jQuery.extend(jQuery, {
"eachIn": function(obj, callback) {
var ensureHas = function(key, val) {
if (obj.hasOwnProperty(key)) {
return callback(key, val);
}
}
return this.each(obj, ensureHas);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment