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" ...
随机推荐
- iOS crash 崩溃问题的追踪方法
http://www.cnblogs.com/easonoutlook/archive/2012/12/27/2835884.html iOS crash 崩溃问题的追踪方法 在调试程序的时候,总是碰 ...
- iphone CGBitmapContextCreate()函数解释
http://blog.sina.com.cn/s/blog_3e50cef401019cd2.html CGContextRef CGBitmapContextCreate ( void *data ...
- Synthesis of memory barriers
A framework is provided for automatic inference of memory fences in concurrent programs. A method is ...
- 多目录,多可执行文件的Makfile的编写
1.前言 在目前的工作中,我遇到这样的一个工作情景,可以认为我要开发一个库,这个库的有多个模块,每个模块的.c放到src中,.h放到include中,这应该是个标准做法. drwxr-xr-x. ro ...
- 编程中的runtime_error问题
前几天在编程中,代码如下: 头文件:ErrorHandlingModule.h //filename:ErrorHandlingModule.h #ifndef ErrorHandlingModule ...
- Linux虚拟地址空间布局以及进程栈和线程栈总结
原文链接:http://blog.csdn.net/freeelinux/article/details/53782986[侵删] 本文转自多个博客,以及最后有我的总结.我没有单独从头到尾写一个总结的 ...
- DropZone图片上传控件的使用
前台代码: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w ...
- UVALive 6451:Tables(模拟 Grade D)
VJ题目链接 题意:模拟输出表格 思路:模拟……很暴力 代码: #include <cstdio> #include <cstring> #include <cstdli ...
- 使用windos电脑模拟搭建web集群(一)
资源规划 1.环境准备 centos7.2 虚拟机 13个 可以先配置一台,做好基础优化,然后克隆13台分布在 windos宿主机上 两台windos笔记 都是8g的内存 一台有点内存吃紧. 没有物 ...
- 推荐一个国内的免费公共静态cdn
https://cdn.baomitu.com/ 更新速度比bootcdn要快,收录的库也很齐全.