reverseObject

/** * Reverses object and returns reversed key/values in callback * @param obj object which is beigh reversed * @param callback function ex.: function (key){ console.log('KEY:', key, 'VALUE:', this[key]); }) */ function reverseObj(obj, callback) { var arr = [], key, i; loop(obj, function (value, key) { arr.push(key); }); for (i = arr.length - 1; i >= 0; i -= 1) { callback.call(obj, arr[i]); } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.