Guest User

Untitled

a guest
May 17th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. /**
  2. * Iterate collection using callback _fn_,
  3. * passing both the value and index.
  4. *
  5. * @param {function} fn
  6. * @return {Collection}
  7. * @api public
  8. */
  9.  
  10. each: function(fn) {
  11. try {
  12. if (this.arr.forEach)
  13. this.arr.forEach(fn)
  14. else
  15. for (var key in this.arr)
  16. if (this.arr.hasOwnProperty(key))
  17. fn(this.arr[key], key)
  18. }
  19. catch (e) {
  20. if (e != $break) throw e
  21. }
  22. return this
  23. }
Add Comment
Please, Sign In to add comment