aboutsummaryrefslogtreecommitdiff
path: root/node_modules/core-js/modules/es6.array.last-index-of.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/core-js/modules/es6.array.last-index-of.js')
-rw-r--r--node_modules/core-js/modules/es6.array.last-index-of.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/node_modules/core-js/modules/es6.array.last-index-of.js b/node_modules/core-js/modules/es6.array.last-index-of.js
new file mode 100644
index 00000000..1f70e340
--- /dev/null
+++ b/node_modules/core-js/modules/es6.array.last-index-of.js
@@ -0,0 +1,22 @@
+'use strict';
+var $export = require('./_export');
+var toIObject = require('./_to-iobject');
+var toInteger = require('./_to-integer');
+var toLength = require('./_to-length');
+var $native = [].lastIndexOf;
+var NEGATIVE_ZERO = !!$native && 1 / [1].lastIndexOf(1, -0) < 0;
+
+$export($export.P + $export.F * (NEGATIVE_ZERO || !require('./_strict-method')($native)), 'Array', {
+ // 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex])
+ lastIndexOf: function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) {
+ // convert -0 to +0
+ if (NEGATIVE_ZERO) return $native.apply(this, arguments) || 0;
+ var O = toIObject(this);
+ var length = toLength(O.length);
+ var index = length - 1;
+ if (arguments.length > 1) index = Math.min(index, toInteger(arguments[1]));
+ if (index < 0) index = length + index;
+ for (;index >= 0; index--) if (index in O) if (O[index] === searchElement) return index || 0;
+ return -1;
+ }
+});