Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function each(object, callback) {
- var item;
- if (object.length != null) {
- // for array with an empty string in it, the conditional causes iteration to stop at the empty string
- for (var i = 0; i < object.length; i++) {
- callback(object[i], i);
- }
- } else {
- for (var key in object) {
- if (object.hasOwnProperty(key)) {
- callback(object[key], key);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment