es6 - array for-chrome
// 去重复
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); //
es6 - array for-chrome的更多相关文章
- 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 ...
- es5||es6 - array
导航目录 /** * javascript - array * * ES5: * join() * push() * pop() * shift() * unshift() * sort() * re ...
- es6 Array.from + new Set 去重复
// es6 set数据结构 生成一个数据集 里面的元素是唯一的 const items = new Set([1, 2, 3, 4, 5, 5, 5, 5]); // items 是个对象 item ...
- 解决低版本chrome浏览器不支持es6 Array.find()
if (!Array.prototype.find) { Array.prototype.find = function(predicate) { 'use strict'; if ( ...
- IE 浏览器不支持 ES6 Array.from(new Set( )) SCRIPT438: 对象不支持“from”属性
[转]解决老浏览器不支持ES6的方法 现象: Array.from(new Set( )) SCRIPT438: 对象不支持“from”属性或方法 解决方法: 安装babel 引入browser. ...
- [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( ...
- [ES6] Array.find()
Convenient method to find one item in an array, avoid writing and for + if: let arys = [1,,5,,6] ; ...
- [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 ...
- es6 Array数组方法
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
随机推荐
- linu触摸屏幕
一..前提知识 1.Linux输入子系统(Input Subsystem): 在Linux中,输入子系统是由输入子系统设备驱动层.输入子系统核心层(Input Core)和输入子系统事件处理层(Eve ...
- 关于Bootstrap 利用radio实现tab切换的一个问题
1.html代码 <div class="col-sm-10 nav nav-tabs" id="typelist" role="tablist ...
- IaaS, PaaS和SaaS
原文链接:http://www.leiphone.com/news/201406/iaas-paas-and-saas.html 云服务”现在已经快成了一个家喻户晓的词了.如果你不知道PaaS, Ia ...
- zepto.js 自定义打包集成其他模块构建流程
1.首先在自己的电脑上要安装Node.js和npm包管理工具: 2.从github上下载zepto.js的源文件包到本地磁盘(例如:E:\Learning\JS): 地址:https://github ...
- 大(NOIP模拟赛Round #10)
题目描述: 小Z有个n个点的高清大图,每个点有且只有一条单向边的出边.现在你可以翻转其中的一些边,使他从任何一个点都不能通过一些道路走回这个点.为了方便,你只需输出方案数对取模即可.当在两个方案中有任 ...
- xen 保存快照的实现之 —— device model 状态保存
xen 保存快照的实现之 —— device model 状态保存 实现要点: 设备状态保存在 /var/lib/xen/qemu-save.x 文件这个文件由 qemu-dm 产生,也由 qemu- ...
- python--math
>>> import math >>> >>> # ceil,取大于等于x的最小的整数值 >>> math.ceil(4) 4 ...
- django rest framework如何实现nest field显示,如何保存有外键的字段更新
一步一步深入了. 相关设置技巧如下: 直接nest field显示: class VersionPoolSerializer(serializers.ModelSerializer): site_na ...
- Codeforces Round #164 (Div. 2) A. Games【暴力/模拟/每个球队分主场和客场,所有球队两两之间进行一场比赛,要求双方球服颜色不能相同】
A. Games time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...
- log4j - 1
具体内容: 1. 如何在项目中配置log4j使得该系统可以输出web test的日志文件(自定义格式)到工程dist目录下的junitLog/WebTestLog.log目录下,输出508 ...