arrayEach.js 307 B

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