当前位置:网站首页>ES6数组新增属性
ES6数组新增属性
2022-07-27 14:55:00 【sl105105】
var arr = [1, 2, 3, 4, 5];
arr.forEach(function (itme) {
console.log(arr);
})
var arr = [1, 2, 3, 4, 5];
var res = arr.map(function (itme) {
// 第一种利用Math.pow()
// return Math.pow(itme, 2)
// 第二种利用Es6的方法**次幂
return itme ** 2
})
console.log(res); var res = person.filter(function (itme, index, array) {
return itme.age > 18
})
console.log(res);
// 练习: 有如下数组, 问: 好人有哪些 ? 坏人有哪些 ?
var acts = [{
name: "大蛇丸",
isGood: false
},
{
name: "卡卡西",
isGood: true
},
{
name: "宇智波斑",
isGood: false
},
{
name: "鸣人",
isGood: true
}]
var res = acts.filter(function (itme) {
// 注意isGood本身就是一个布尔类型,所以不用==true
// 好人
// return itme.isGood
// 坏人
return !itme.isGood
})
console.log(res)
function fn(person) {
return person.age > 20
}
console.log(person.find(fn)); var res = person.find(function (itme, index, array) {
return itme.age > 20
})
console.log(res);
var arr = [1, 2, 3, 4, 5];
var str = arr.findIndex(function (itme) {
return itme > 3
})
console.log(str);
var res = person.every(function (itme) {
return itme.age >= 18
})
console.log(res ? "全部满足" : "有一个不满足");
var res = person.some(function (itme) {
return itme.age < 18
})
console.log(res ? "有" : "无");
var arr = [1, 2, 3, 4, 5];
var res = arr.reduce(function (acc, cur) {
return acc * cur
// return acc + cur
}, 10)
console.log(res); var arr = [6, 22, 3, 1, 55]
console.log(arr.toString()); // 伪数组:只有length属性
// 第一种:argumentes
function add(a, b) {
console.log(arguments);
}
add(1, 2, 3, 4, 5)
// 第二种: 字符串
var str="abcd"
console.log(str[0]);
// 第三种:DOM树
var dom=document.getElementsByTagName("p")
console.log(dom);
function add(a, b) {
var arr = Array.from(arguments)
console.log(arr);
}
add(1, 2, 3, 4, 5)function add(a, b) {
var arr = [...arguments]
console.log(arr);
}
add(1, 2, 3, 4, 5)




边栏推荐
- 201403-1
- [paper reading] a CNN transformer hybrid approach for cropclassification using multitemporalmultisensor images
- Share a scheme of "redis" to realize "chat round system" that can't be found on the Internet
- MPC_ ORCA
- 2021-05-30
- C语言之字符函数和字符串函数及内存函数
- JSON data parsing
- Implementation of ByteDance service grid based on Hertz framework
- LNMP environment - deploy WordPress
- LOJ 576 - "libreoj noi round 2" sign in game [line segment tree]
猜你喜欢
![[paper reading] transformer with transfer CNN for remote sensing imageobject detection](/img/a2/8ee85e81133326afd86648d9594216.png)
[paper reading] transformer with transfer CNN for remote sensing imageobject detection

Quadratic programming based on osqp

Clear understanding of torchvision (mind map)

Operators of C language

Simulation generate report

Jupyter creates a virtual environment and installs pytorch (GPU)
![[paper reading] a CNN transformer hybrid approach for coding visual neuralactivity into text](/img/31/d6d7ac43c3170c0d527d88053618c9.png)
[paper reading] a CNN transformer hybrid approach for coding visual neuralactivity into text

C语言之文件操作

CODIS cluster deployment

AS更换背景主题以及背景图片
随机推荐
Configuration and application of gurobi in pycharm
Json数据的格式使用
[paper reading] single- and cross modality near duplicate image pairsdetection via spatial transformer compare
Servlet Chinese garbled setcontenttype setting is invalid
ROS - error in running.Py file in the project
JDBC连接数据库
从零开始Blazor Server(1)--项目搭建
[paper reading] a CNN transformer hybrid approach for coding visual neuralactivity into text
Log4j.jar and slf4-log4 download link
Opencv (V) -- moving target recognition
Pdf extract text
json数据解析
training on multiple GPUs pytorch
Jupyter creates a virtual environment and installs pytorch (GPU)
Implementation of ByteDance service grid based on Hertz framework
Circular statements and arrays
Is low code the future of development? On low code platform
C语言之指针进阶
Clear understanding of torchvision (mind map)
log4j.jar和slf4-log4下载链接