for-each-right.js 587 B

12345678910111213141516171819
  1. "use strict";
  2. var toPosInt = require("../../number/to-pos-integer")
  3. , callable = require("../../object/valid-callable")
  4. , value = require("../../object/valid-value")
  5. , objHasOwnProperty = 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 (objHasOwnProperty.call(self, i)) call.call(cb, thisArg, self[i], i, self);
  14. }
  15. };