解决了IE8不支持数组的indexOf方法
ie在过去给我们添了很多坑。
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;
};
}
解决了IE8不支持数组的indexOf方法的更多相关文章
- 终于解决了IE8不支持数组的indexOf方法,array的IndexOf方法
/* 终于解决了IE8不支持数组的indexOf方法 */ if (!Array.prototype.indexOf) { Array.prototype.indexOf = function (el ...
- IE8不支持数组的indexOf方法 如何解决
转自:http://www.jbxue.com/article/8367.html 原因分析: 这是一个js bug, 在IE8下,js数组没有indexOf方法,会报错:而在其它浏览器下(Firef ...
- IE8不支持数组的indexOf方法
在IE8下有个js错误,但是在其它浏览器下(Firefox, Chrome, IE9)下面都很正常.后来调试发现原因是在IE8下,js数组没有indexOf方法. 在使用indexOf方法前,执行一下 ...
- js解决IE不支持数组的indexOf()方法
if (!Array.indexOf) { Array.indexOf = function (obj) { ...
- JavaScript——数组的indexOf()方法在IE8中的兼容性问题
昨天在工作中遇到一个问题:数组的indexOf()方法在IE8中无效. 如以下代码在IE8中报错“对象不支持“indexOf”属性或方法”: var arr = [1,2,3]; var index ...
- JavaScript—从数组的indexOf方法深入——Object的Property机制。
在js中,可以说万物皆对象(object),一个数组也是一个对象(array). 很多对象都有很多很方便的方法 比如数组的push,concat,slice等等,但是如果一些对象,它没有实现这些方法, ...
- js 判断数组包含某值的方法 和 javascript数组扩展indexOf()方法
var questionId = []; var anSwerIdValue = []; ////javascript数组扩展indexOf()方法 Array.prototype.indexOf ...
- 数组的indexOf方法--数组去重
数组的indexOf方法 数组方法大家再熟悉不过了,却忽略了数组有 indexOf 这个方法(我个人感觉). 干说不练瞎扯淡,遇到了什么问题,注意⚠️点又在哪里? let arr = ['orange ...
- Javascript中的数组去重-indexof方法
在Javascript中,有时我们会用到数组去重.我在这里给大家介绍一下本人认为最简单实用的一种方法-indexOf()去重. var arr = [1,1,1,2,2,2,3,3,4,5,6,2,1 ...
随机推荐
- .Net程序员的前端优化
面向.Net程序员的前端优化 2014-08-06 17:20 by 熬夜的虫子, 1152 阅读, 9 评论, 收藏, 编辑 背景 作为web开发人员大家大多了解一些网站的性能优化方法,其实大部分方 ...
- Ubuntu下安装Python绘图库Matplotlib的方法
在安装好Python的基础上, sudo apt-get install python-numpy sudo apt-get install python-scipy sudo apt-get ins ...
- Summation of Four Primes - PC110705
欢迎访问我的新博客:http://www.milkcu.com/blog/ 原文地址:http://www.milkcu.com/blog/archives/uva10168.html 原创:Summ ...
- HOJ:2031 进制转换
进制转换 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- android通过程序收起通知栏
1. 添加权限 <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" /> 2. ...
- ssh配置公钥和私钥登陆SecureCRT
在用windows时管理linux服务器时,常会用到SecureCRT.Xshell以及开源的putty.在我工作环境大多都是采用密码认证的方式进行登录.今天对学习了些SecureCRT的密钥登录方式 ...
- [转]About the security content of iOS 8
Source:http://support.apple.com/kb/HT6441 For the protection of our customers, Apple does not disclo ...
- iOS: JS和Native交互的两种方法
背景: UIWebView: iOS 用来展示 web 端内容的控件. 1. 核心方法: - (NSString*)stringByEvaluatingJavaScriptFromString:(NS ...
- 记一次有趣的互联网事件及console.log~
寂寞的中国互联网又一次瘫痪了. 说是顶级域的根挂了,不知道是黑客还是某个实习生干挂的. 反正到现在还没有人来解释这件事. 先普及一下,为什么顶级域的根挂了全中国都挂了. 那是因为dns解析的特点是递归 ...
- 基于 WebSocket 构建跨浏览器的实时应用
Socket.IO – 基于 WebSocket 构建跨浏览器的实时应用 Socket.IO 是一个功能非常强大的框架,能够帮助你构建基于 WebSocket 的跨浏览器的实时应用.支持主流浏览器,多 ...