• YUI Array 之dedupe(快速去重)


    YUI.Array.dedupe函数,如果传参为有length属性,返回一个去除掉重复项('1’ 与1 | true 与'true’认为相等)的参数数组副本,如果传参的length为undefined,那么返回一个空数组[],如果传参没length属性,抛出一个类型错误

    数组去重

    1.  在一个对象obj中 obj[1] === obj['1’]    obj[true] === obj[‘true’]

    2.  这个函数不会去比较数据类型,如果一个值在空对象中没值,则赋值为1,并将它push进数组,下次有相同的值,直接略过

    3.  在现代浏览器中,可以直接调用Obejct.create(),构建一个没有原型的对象,但在ie8及以下中,直接创建一个{},每次还要用hasOwnProperty去检测是否是{}的属性,再去执行2的操作,速度减慢

    对象
  • 相关阅读:
    hdu 5726 GCD
    codeforces 982C Cut 'em all!
    codeforces 982B Bus of Characters
    codeforces 982A Row
    codeforces 983B XOR-pyramid
    codeforces 979D Kuro and GCD and XOR and SUM
    codeforces 983A Finite or not?
    codeforces 984B Minesweeper
    codeforces 979C Kuro and Walking Route
    codeforces 979B Treasure Hunt
  • 原文地址:https://www.cnblogs.com/fsy0718/p/3287875.html
Copyright © 2020-2023  润新知