标签:pca document tor 开始 [] qml 回调 array console
const a = [1,2,3];
const b = a.concat();
console.log(b);
// [1,2,3]
let arrayLike = {
‘0‘: ‘a‘,
‘1‘: ‘b‘,
‘2‘: ‘c‘,
length: 3
};
const arr = Array.from(arrayLike);
console.log(arr);
// [‘a‘,‘b‘,‘c‘]
// DOM 对象也是一个类数组对象
const ps = document.querySelectorAll(‘p‘);
const nodeList = Array.from(ps);
const arr = [1,2,3,1];
const newArr = new Set(arr);
console.log(newArr);
// [1,2,3]
// 无法对以下数组进行去重
const arr = [{id:1,name:‘a‘},{id:1,name:‘b‘}];
var arr = [1,2,3,4,5,6];
arr.some(item => (item > 3));
// true
var arr = [1,2,3,4,5,6];
arr.filter(item => (item > 3));
// [4,5,6]
const arr = [1,2,3,4];
arr.reduce((previousValue, currentValue, index, array) => {
retrun previousValue + currentValue;
}, initialValue)
// 10
const arr = [1,2,3,4];
arr.map(item => item + 1);
// [2,3,4,5]
const arr = [1,2,3,4];
const newArr = [];
arr.forEach(item => newArr.push(item + 1))
console.log(newArr);
// [2,3,4,5]
标签:pca document tor 开始 [] qml 回调 array console
原文地址:https://www.cnblogs.com/shuia/p/9300409.html