Version 1
[yaffs-website] / node_modules / core-js / library / modules / es6.array.last-index-of.js
1 'use strict';
2 var $export       = require('./_export')
3   , toIObject     = require('./_to-iobject')
4   , toInteger     = require('./_to-integer')
5   , toLength      = require('./_to-length')
6   , $native       = [].lastIndexOf
7   , NEGATIVE_ZERO = !!$native && 1 / [1].lastIndexOf(1, -0) < 0;
8
9 $export($export.P + $export.F * (NEGATIVE_ZERO || !require('./_strict-method')($native)), 'Array', {
10   // 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex])
11   lastIndexOf: function lastIndexOf(searchElement /*, fromIndex = @[*-1] */){
12     // convert -0 to +0
13     if(NEGATIVE_ZERO)return $native.apply(this, arguments) || 0;
14     var O      = toIObject(this)
15       , length = toLength(O.length)
16       , index  = length - 1;
17     if(arguments.length > 1)index = Math.min(index, toInteger(arguments[1]));
18     if(index < 0)index = length + index;
19     for(;index >= 0; index--)if(index in O)if(O[index] === searchElement)return index || 0;
20     return -1;
21   }
22 });