zoukankan      html  css  js  c++  java
  • Array.prototype.includes

    if (!Array.prototype.includes) {
      Array.prototype.includes = function(searchElement /*, fromIndex*/ ) {
        'use strict';
        var O = Object(this);
        var len = parseInt(O.length) || 0;
        if (len === 0) {
          return false;
        }
        var n = parseInt(arguments[1]) || 0;
        var k;
        if (n >= 0) {
          k = n;
        } else {
          k = len + n;
          if (k < 0) {k = 0;}
        }
        var currentElement;
        while (k < len) {
          currentElement = O[k];
          if (searchElement === currentElement ||
             (searchElement !== searchElement && currentElement !== currentElement)) {
            return true;
          }
          k++;
        }
        return false;
      };
    }
  • 相关阅读:
    多进程多线程
    JS---闭包
    Canvas:时钟
    CANVAS画布与SVG的区别
    CSS盒模型
    CSS---伪类与伪元素的区别
    CSS生成内容
    利用画布绘制折线图
    uiwebview与objective-c
    GoBelieve JS IM SDK接入备忘
  • 原文地址:https://www.cnblogs.com/shidengyun/p/5441207.html
Copyright © 2011-2022 走看看