// 去重复
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. touchSlider插件案例

    <!doctype html> <html lang="en"> <head> <title>jQuery手机图片触屏滑动轮播效果代 ...

  2. windows实时监测热插拔设备的变化2

    //动态监测设备插拔 #include <Dbt.h> BEGIN_MESSAGE_MAP(ParticipateMeeting, CDialogEx) ON_WM_DEVICECHANG ...

  3. matlab7 + sqlitejdbc-v056.jar出现错误

    conn=database('data.db','','','org.sqlite.JDBC','jdbc:sqlite:C:/MATLAB7/work/del_man_voice_from_wave ...

  4. linux内存管理2:内存映射和需求分页(英文名字:demand Paging,又叫:缺页中断)【转】

    转自:http://blog.csdn.net/zhangxinrun/article/details/5873148 当某个程序映象开始运行时,可执行映象必须装入进程的虚拟地址空间.如果该程序用到了 ...

  5. springboot结合swagger自动生成接口文档

    前后台分离的开发渐渐已成趋势.那么前后端的沟通就成了问题,包括移动端,web端.如果有一个东西在我们写完代码的时候,自动将接口的所有注释,调用文档提供出来,是不是一件很美好的事情.那就是使用swagg ...

  6. hdu 1811(缩点+拓扑排序+并查集)

    Rank of Tetris Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  7. 使用百度地图JavaScript实现驾车/公交/步行导航功能

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  8. CDH-5.7.0:基于Parcels方式离线安装配置

    http://shiyanjun.cn/archives/1728.html https://www.waitig.com/cdh%E5%AE%89%E8%A3%85.html

  9. C# Quartz 整理

    因项目需要,在C#中使用了定时程序.自然就使用了Quartz了 但是使用的时候,经过一段时间后,发现了两个重大问题,结果导致的是一样的,就是都导致了定时不会继续执行了. 第一个问题是,定时程序发布在I ...

  10. Guava源码学习(三)ImmutableCollection

    基于版本:Guava 22.0 Wiki:Immutable collections 0. ImmutableCollection简介 类似于JDK的Collections.unmodifiableX ...