// 去重复
Array.from(new Set([1, 1, 2, 3])); // [1, 2, 3]
console.log(Array.from(new Set([1, 1, 2, 3]))); // 分解字符串
Array.from('hello'); // ["h", "e", "l", "l", "o"]
console.log(Array.from('hello')); // 转换为ascill
Array.from('hello', x => x.charCodeAt(0)); // [104, 101, 108, 108, 111]
let ascill = Array.from('hello', x => x.charCodeAt(0));
console.log(ascill, typeof (ascill)); // 获取节点
let divs = document.querySelectorAll('div');
Array.from(divs).forEach(function (node) {
console.log(node);
}); // 数组合并
let i = [2, 3, 5, 6];
let j = [1, 2, 3, 4];
let k = Array.of('hello', 666, i, j);
console.log(k);
Array.of('hello'); // ["hello"]
Array.of(1, 2, 3); // [1, 2, 3]
Array.of('blink', 182); // ["blink", 182] // 替换数组内容
// target = 数组位置(3) ,目标等于start数组位置内(0 ~ array.length-1)
let copyWithin1 = [0, 1, 2, 3, 4].copyWithin(target = 3, start = 0);
console.log('copyWithin1:', copyWithin1); // target = 数组位置(3) ,目标等于start数组位置内(0 ~ array.length-1),结束位置是4
let copyWithin2 = [0, 1, 2, 3, 4].copyWithin(target = 0, start = 3, end = 4); // [3, 1, 2, 3, 4]
console.log('copyWithin2:', copyWithin2); // fill - 填充
[0, 1, 2, 3, 4].fill(5); // [5, 5, 5, 5, 5]
// 第二个以后开始fill填充
[0, 1, 2, 3, 4].fill(5, start = 2); // [0, 1, 5, 5, 5]
// 第二个开始填充,下标4结束.
[0, 1, 2, 3, 4].fill(5, start = 2, end = 4); // [0, 1, 5, 5, 4] // 字符串包含 - es6
function startsWithLetterA(e, index, array) {
// 包含开头内容a - es6 字符串搜索
console.log(e, index, array);
if (e.startsWith('a')) {
return e;
}
}
var cuteNames = ['jeff', 'marc', 'addy', 'francois'];
cuteNames.find(startsWithLetterA); // "addy" // 字符串包含 - 返回下标
function startsWithLetterA(element, index, array) {
if (element.startsWith('a')) {
return element;
}
}
var cuteNames = ['jeff', 'marc', 'addy', 'francois']; cuteNames.findIndex(startsWithLetterA); //
END...

es6 - array for-chrome的更多相关文章

  1. vue.js 进行初始化遇到的关于core-js的错误@core-js/modules/es6.array.find-index]

    D:\vuejselement\workSpace\zutnlp_platform_show>cnpm install --save core-js/modules/es6.array.find ...

  2. es5||es6 - array

    导航目录 /** * javascript - array * * ES5: * join() * push() * pop() * shift() * unshift() * sort() * re ...

  3. es6 Array.from + new Set 去重复

    // es6 set数据结构 生成一个数据集 里面的元素是唯一的 const items = new Set([1, 2, 3, 4, 5, 5, 5, 5]); // items 是个对象 item ...

  4. 解决低版本chrome浏览器不支持es6 Array.find()

     if (!Array.prototype.find) {  Array.prototype.find = function(predicate) {    'use strict';    if ( ...

  5. IE 浏览器不支持 ES6 Array.from(new Set( )) SCRIPT438: 对象不支持“from”属性

    [转]解决老浏览器不支持ES6的方法 现象: Array.from(new Set( )) SCRIPT438: 对象不支持“from”属性或方法   解决方法: 安装babel 引入browser. ...

  6. [ES6] Array.findIndex()

    In es5, you can use indexOf to get the index of one item in an array. In es6, you can use findIndex( ...

  7. [ES6] Array.find()

    Convenient method to find one item in an array, avoid writing and  for + if: let arys = [1,,5,,6] ; ...

  8. [ES6] Array -- Destructuring and Rest Parameters && for ..of && Arrat.find()

    We can use the destructing and rest parameters at the same time when dealing with Array opration. Ex ...

  9. es6 Array数组方法

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

随机推荐

  1. fmap为什么可以用function作为第二个参数

    看看fmap的类型 fmap :: Functor f => (a -> b) -> f a -> f b 很明显的,第一个参数是function,第二个参数是functor的 ...

  2. kvm虚拟机最佳实践系列2-创建KVM及KVM优化

    创建KVM及KVM优化 把KVM优化与KVM创建放在一起,是因为我们创建的KVM是要用在生产环境中,所以基础优化工作是必备的. 创建KVM 创建系统盘, 大小: 操作系统通常都不到10G,所以系统盘2 ...

  3. Nginx整合PHP原理

    安装Nginx        在网上,看到不少人装Nginx 时非常麻烦,配置时用了一大堆选项,请问你们真实现那么多功能么?害的我越看越郁闷.此次安装Nginx如果是按着上面笔者的步骤一步步走下来,安 ...

  4. python enumerate元素的时候可以获取下标,并且可以指定开始的下标值。

    list=["a","b","c","d","e"] for i,item in enumerate ...

  5. rgmanager 介绍

    版本: rgmanager-2.0.52-14.el6.x86_64 服务: /etc/init.d/rgmanager 配置文件: /etc/cluster/cluster.conf 日志文件: 相 ...

  6. HDU 6108.小C的倍数问题 (2017"百度之星"程序设计大赛 - 初赛(A)1001)

    补完题?不存在的. 这么久了,还是一条咸鱼,看一堆乱七八糟的东西,写一堆没用的水题,一点进步都没有,还是那么菜,菜的掉渣. 这个百毒之星初赛A还会写两道最简单的水题,初赛B一点也不会,菜的难过... ...

  7. codeforces-505B

    题目连接:http://codeforces.com/contest/505/problem/B B. Mr. Kitayuta's Colorful Graph time limit per tes ...

  8. poj2976(01分数规划)

    poj2976 题意 给出 a b 数组,一共 n 对数,其中最多可以去掉 k 对,问怎样使剩下比率(原始比率是 $ \frac{\sum_{i=1}^{n} a}{\sum_{i=1}^{n} b} ...

  9. [CTSC2018]假面(概率DP)

    考场上以为CTSC的概率期望题都不可做,连暴力都没写直接爆零. 结果出来发现全场70以上,大部分AC,少于70的好像极少,感觉血亏. 设a[i][j]表示到当前为止第i个人的血量为j的概率(注意特判血 ...

  10. 访问控制技术- 扩展IP访问列表

    1.设置pc IP 网关 192.168.1.1 192.168.1.254 192.168.1.2 192.169.1.254 192.168.3.1 192.168.3.254 192.168.3 ...