// ============   isArray  ===============//
// isArray
function isArray(value){
return Object.prototype.toString.call(value) == "[object Array]";
}
var arr = [1,2,3,4,5];
alert(isArray(arr)); // IE8 及以下不支持
  // ============   filter 等  ===============//
// 数组的一些方法 every(), filter(), forEach(), map(), some()
// IE8 及以下不支持
// 解决办法,以filter为例,自己写一个filter
if (!Array.prototype.filter) {
Array.prototype.filter = function(fun /*, thisp*/){
var len = this.length;
if (typeof fun != "function"){
throw new TypeError();
}
var res = new Array();
var thisp = arguments[1];
for (var i = 0; i < len; i++){
if (i in this){
var val = this[i]; // in case fun mutates this
if (fun.call(thisp, val, i, this)) {
res.push(val);
}
}
}
return res;
};
} var numbers = [1,2,3,4,5,6];
var filterResult = numbers.filter(function(item, inde, array){
return (item>2);
});
alert(filterResult); // 3,4,5,6
    // ============   Date.now()  ===============//
// Date.now(); IE8及以下不支持,只能自己写一个解决
if(!Date.now){
Date.now = function(){
return new Date().valueOf();
}
}
alert(Date.now());
   // ============   stringValue[1]  ===============//
// 在IE7 及以下版本显示 undefined
var stringValue = "hello world";
alert(stringValue[1]);
 
    // ============   trim()  ===============//
// 在IE8 及以下版本无效,需要自己写
String.prototype.trim = function(){
return this.replace(/(^\s*)(\s*$)/g, "");
}; var stringValue2 = " hello world ";
alert(stringValue2.trim());

javascript的一些在IE下不支持的函数小结的更多相关文章

  1. Linux 多线程环境下 进程线程终止函数小结(转)

    pthread_kill: pthread_kill与kill有区别,是向线程发送signal.,大部分signal的默认动作是终止进程的运行,所以,我们才要用signal()去抓信号并加上处理函数. ...

  2. 使用javascript实现html页面直接下载网盘文件

    公司新建一网站,用的是商派的易开店系统.设计方案中有一个是下载文件的功能,但易开店不支持上传资源,所以无法下载本站资源. 于是想到了网盘资源下载,有些网站是把页面链接到网盘资源文件下载页面,进行二次跳 ...

  3. JavaScript 定义类的最佳写法——完整支持面向对象(封装、继承、多态),兼容所有浏览器,支持用JSDuck生成文档

    作者: zyl910 [TOC] 一.缘由 由于在ES6之前,JavaScript中没有定义类(class)语法.导致大家用各种五花八门的办法来定义类,代码风格不统一.而且对于模拟面向对象的三大支柱& ...

  4. max-height,min-height在IE下不支持的解决方法

    max-height,min-height在IE下不支持的解决方法 max-width:160px; max-height:160px; _width:expression(this.width &g ...

  5. Javascript检测浏览器对CSS属性的支持 /* supports */

    //检测浏览器对CSS属性的支持 supports = (function() { var div = document.createElement('div'), vendors = 'Khtml ...

  6. javascript实现可编辑的下拉框

    曾经遇到过一个需求的情况是这样的,我们提供给用户的输入框的可选择项只能满足用户的大部分情况的选择,但是有时候会遇到一些用户想要输入的数据是下拉项中所没有的,而用户不希望改变下拉项为输入框模式,需要说如 ...

  7. windows Apache 环境下配置支持HTTPS的SSL证书

    windows Apache 环境下配置支持HTTPS的SSL证书 1.准备工作 1)在设置Apache + SSL之前, 需要做: 安装Apache, 下载安装Apache时请下载带有SSL版本的A ...

  8. Mac系统下编译支持Android平台的最新X264编码器

    Mac系统下编译支持Android平台的最新X264编码器 原文来自 http://www.mingjianhua.com,转载请注明出处 1.首先去官网下载最新的x264源代码,解压到任意目录 ht ...

  9. centos7.3下curl支持https协议

    1 由于自己的curl是默认安装的,查看了下 不支持https协议 [root@izwz90bp6do7s3cr45cw6az ~]# curl --version curl (x86_64-redh ...

随机推荐

  1. 怎么设置输入的EditText字母自己主动大写

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/t80t90s/article/details/25048917 复于: 2013-09-06 09: ...

  2. 【从0開始Tornado建站】显示全部注冊用户

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/littlethunder/article/details/25559749         显示注冊 ...

  3. HTTP API响应数据规范整理

    概述 本文档为本人对长期开发API接口所整理的经验总结,如有不完善或不合理的地方,望各位多提意见. 文档目的为规范服务器端API接口,便于服务器端与客户端代码重用.服务器端和客户端可根据实际所定义规范 ...

  4. Docker 后台进程参数-------更改Docker运行根目录的方法

    参数 介绍 --api-enable-cors=false 远程API调用. -b, --bridge="" 桥接一个系统上的网桥设备到 Docker 容器里,当使用 none 可 ...

  5. 自动生产jason的工具

    EnjoySR/ESJsonFormat-Xcode

  6. redis的5种数据结构的使用场景介绍

    一.redis 数据结构使用场景 原来看过 redisbook 这本书,对 redis 的基本功能都已经熟悉了,从上周开始看 redis 的源码.目前目标是吃透 redis 的数据结构.我们都知道,在 ...

  7. json 的相互 转换

    using System.Runtime.Serialization.Json; //json 转化为List集合 public List<T> JSONStringToList<T ...

  8. npm包上传下载的命令及例子

    npm包上传下载的命令及例子. 新建hello.js 执行:npm init 执行:npm adduser ( username:XXX password:XXX email:XXX ) 上传:npm ...

  9. GUN C中的attribute

    GNU C 的一大特色就是__attribute__ 机制.__attribute__ 可以设置函数属性(Function Attribute ).变量属性(Variable Attribute )和 ...

  10. SV中的task和function

    SV中class的properties和methods默认都是public的,但是可以声明为local和protected. 一个properties声明为local类型的,则只在该class中的me ...