ie8 不兼容的方法

$(function(){
//添加数组IndexOf方法
if (!Array.prototype.indexOf){
Array.prototype.indexOf = function(elt /*, from*/){
var len = this.length >>> 0; var from = Number(arguments[1]) || 0;
from = (from < 0)
? Math.ceil(from)
: Math.floor(from);
if (from < 0)
from += len; for (; from < len; from++){
if (from in this && this[from] === elt)
return from;
}
return -1;
};
} //getOwnPropertyNames keys 方法
if(!Object.getOwnPropertyNames || !Object.keys){
Object.keys = Object.getOwnPropertyNames = function(temp){
var A = [];
for(var key in temp){
A.push(key);
}
return A;
}
} //forEach 方法
if ( !Array.prototype.forEach ) {
Array.prototype.forEach = function forEach( callback, thisArg ) {
var T, k;
if ( this == null ) {
throw new TypeError( "this is null or not defined" );
}
var O = Object(this);
var len = O.length >>> 0;
if ( typeof callback !== "function" ) {
throw new TypeError( callback + " is not a function" );
}
if ( arguments.length > 1 ) {
T = thisArg;
}
k = 0;
while( k < len ) {
var kValue;
if ( k in O ) {
kValue = O[ k ];
callback.call( T, kValue, k, O );
}
k++;
}
};
} //filter 方法
if (!Array.prototype.filter)
{
Array.prototype.filter = function(fun /*, thisArg */)
{
"use strict"; if (this === void 0 || this === null)
throw new TypeError(); var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function")
throw new TypeError(); var res = [];
var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
for (var i = 0; i < len; i++)
{
if (i in t)
{
var val = t[i]; // NOTE: Technically this should Object.defineProperty at
// the next index, as push can be affected by
// properties on Object.prototype and Array.prototype.
// But that method's new, and collisions should be
// rare, so use the more-compatible alternative.
if (fun.call(thisArg, val, i, t))
res.push(val);
}
} return res;
};
}
})

最新文章

  1. gentoo 安装
  2. DataSnap 2009 系列之三 (生命周期篇)
  3. Perl 随笔
  4. a various of context
  5. git 恢复工作区删除的所有文件
  6. List集合分组
  7. Android 使用Android Studio + Gradle 或 命令行 进行apk签名打包
  8. SSD的基本架构
  9. 打印Ibatis最后,SQL声明
  10. html 5 本地数据库(Web Sql Database)核心方法openDatabase、transaction、executeSql 详解
  11. Java 8中Stream API学习笔记
  12. python的条件语句
  13. java 完全解耦
  14. php支付宝开发
  15. Excel 公式CORREL算出相关系数
  16. VIM各种快捷应用
  17. PostgreSQL 资源
  18. 从知乎了解到,为什么Mysql禁用存储过程、外键和级联?
  19. js区分字符串和数字,有时候需要将字符串转换成数字
  20. js动画杂记

热门文章

  1. PL/SQL DEVELOPER执行计划的查看
  2. 解决LoadRunner超时错误
  3. Springboot框架中request.getInputStream()获取不到上传的文件流
  4. 多线程辅助类-CountDownLatch的用法
  5. UVA-11892(组合游戏)
  6. OpenResty创造者
  7. py-day2-sys模块、os模块、运算符、列表、字典
  8. C#视频取帧图
  9. OO易错点总结
  10. java集合框架之ArrayList与LinkedList的区别