1
0

for-each-right.js 543 B

1234567891011121314151617181920
  1. 'use strict';
  2. var toPosInt = require('../../number/to-pos-integer')
  3. , callable = require('../../object/valid-callable')
  4. , value = require('../../object/valid-value')
  5. , hasOwnProperty = Object.prototype.hasOwnProperty
  6. , call = Function.prototype.call;
  7. module.exports = function (cb/*, thisArg*/) {
  8. var i, self, thisArg;
  9. self = Object(value(this));
  10. callable(cb);
  11. thisArg = arguments[1];
  12. for (i = (toPosInt(self.length) - 1); i >= 0; --i) {
  13. if (hasOwnProperty.call(self, i)) call.call(cb, thisArg, self[i], i, self);
  14. }
  15. };