zoukankan      html  css  js  c++  java
  • Javascript common functions

    The slice() method selects the elements starting at the given start argument, and ends at, but does not include, the given end argument.       

    1. Array.prototype.removeAt = function (index) {
       var part1 = this.slice(0, index);
       var part2 = this.slice(index + 1);
       return part1.concat(part2);

    }

    var a = [10, 11,12,13];
    a.removeAt(2); // remove 12

    2. Array.prototype.indexOf = function (what, i) {
        i = i || 0;
        var L = this.length;
        while (i < L) {
            if (this[i] === what) return i;
            ++i;
        }
        return -1;
    }

    3. Array.prototype.remove = function () {
        var what, a = arguments, L = a.length, ax;
        while (L && this.length) {
            what = a[--L];
            while ((ax = this.indexOf(what)) != -1) {
                this.splice(ax, 1);
            }
        }
        return this;
    }

  • 相关阅读:
    优先队列
    BFS和图的最短路径 279,127,126
    opencv常用函数
    图形图像概念
    缓存
    主板
    显卡
    cpu
    vs配置opencv(只需一次)
    附加依赖项、库目录、包含目录
  • 原文地址:https://www.cnblogs.com/webglcn/p/2642374.html
Copyright © 2011-2022 走看看