1 /** 2 * Hilo 3 * Copyright 2015 alibaba.com 4 * Licensed under the MIT License 5 */ 6 7 var arrayProto = Array.prototype, 8 slice = arrayProto.slice; 9 10 //polyfiil for Array.prototype.indexOf 11 arrayProto.indexOf = arrayProto.indexOf || function(elem, fromIndex){ 12 fromIndex = fromIndex || 0; 13 var len = this.length, i; 14 if(len == 0 || fromIndex >= len) return -1; 15 if(fromIndex < 0) fromIndex = len + fromIndex; 16 for(i = fromIndex; i < len; i++){ 17 if(this[i] === elem) return i; 18 } 19 return -1; 20 }; 21 22 var fnProto = Function.prototype; 23 24 //polyfill for Function.prototype.bind 25 fnProto.bind = fnProto.bind || function(thisArg){ 26 var target = this, 27 boundArgs = slice.call(arguments, 1), 28 F = function(){}; 29 30 function bound(){ 31 var args = boundArgs.concat(slice.call(arguments)); 32 return target.apply(this instanceof bound ? this : thisArg, args); 33 } 34 35 F.prototype = target.prototype; 36 bound.prototype = new F(); 37 38 return bound; 39 };