当前位置:网站首页>(JS) pure function in array
(JS) pure function in array
2022-06-29 11:11:00 【Yu Cainiao, who asked not to be named】
- Do not change the source array ( No side effects )
- Returns an array
- Arrat.concat(value)
Merge arrays and return a new array , Do not change the original array ( And push be similar , Add... At the end of the array value)
let array = [1,2,3,4,5];
let x = array.concat([10,20])
console.log(x) // [1,2,3,4,5,10,20]
- Array.map(function)
Traversal array , If return Output array value , Will become a new array , If judgment is used , The unqualified return false
let array = [1,2,3,4,5];
let x = array.map(result=>{
return result*10;
});
console.log(x) //[10, 20, 30, 40, 50]
- Array.filter(function)
Filter array , Returns a value that meets the criteria
let array = [1,2,3,4,5];
let x = array.filter(num=>{
return num>2
})
console.log(x)//[3, 4, 5]
- Array.slice(start ,end)
Copy array from start To end( barring end) Value , Returns a new array , No changes will be made to the source array
let array = [1,2,3,4,5];
let x = array.slice(2,3)
console.log(array) //[1,2,3,4,5]
console.log(x) //[3]
边栏推荐
- QT writing IOT management platform 37- logic design
- Bs-gx-017 online examination management system based on SSM
- (JS)模仿一个instanceof方法
- Modbustcp protocol network learning single channel infrared module (medium shell version)
- Mysql获取表信息
- 毕业季·进击的技术er - 职场打工人
- 【各种**问题系列】OLTP和OLAP是啥?
- Pipeline aggregations管道聚合- parent-2
- Online sql to htmltable tool
- Mastering the clever use of some shell wildcards will make us write with half the effort
猜你喜欢

Here comes the tutorial of datawhale recommendation system!

容器平台性能如何测试,稳定性、扩展效率、组件性能

非凸联合创始人李佐凡:将量化作为自己的终身事业

TTL serial port learning infrared remote control module can be extended to network control

历史上的今天:马斯克出生;微软推出 Office 365;蔡氏电路的发明者出生

Online sql to htmltable tool

9 款好用到爆的 JSON 处理工具,极大提高效率!

Bs-gx-017 online examination management system based on SSM

Modbus RTU protocol 485 learning 2-way infrared module

【每日3题(3)】重新格式化电话号码
随机推荐
Modbustcp protocol WiFi wireless learning single channel infrared module (small shell version)
misc3~7
How to properly manage temporary files when writing shell scripts
map合并相同的键,值合并为列表
VI exit exit VIM applicable novice
(JS)捕获错误(异常)
最后的 48 小时!云 XR 专题赛邀你一起绽放精彩,我们赛场见!
数据分析方法与思维:漏斗分析
ModbusTCP协议网络学习型单路红外模块(中壳版)
直击产业落地!飞桨重磅推出业界首个模型选型工具
企业竞争分析的几种方法:SWOT、波特五力、PEST「建议收藏」
X-Frame-Options(点击劫持) 网页劫持漏洞
Uboot for embedded driver development -- common command parameters in uboot
第12周实验---基于FPGA的VGA协议实现
如何通过WinDbg获取方法参数值
Week 12 experiment -- implementation of VGA protocol based on FPGA
(JS)迭代器模式
MySQL query table field information
(JS)手写深拷贝
Ningde era Kirin battery has greater ambition