arrayEach.js 300 B

12345678910111213
  1. function arrayEach (obj, iterate, context) {
  2. if (obj) {
  3. if (obj.forEach) {
  4. obj.forEach(iterate, context)
  5. } else {
  6. for (var index = 0, len = obj.length; index < len; index++) {
  7. iterate.call(context, obj[index], index, obj)
  8. }
  9. }
  10. }
  11. }
  12. module.exports = arrayEach