Array.prototype.map()和Array.prototypefilter()
2024-10-18 20:22:43
ES5 => 筛选功能 Array.prototypefilter():
代码:
var words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present']; const result = words.filter(word => word.length > 6); console.log(result);
// expected output: Array ["exuberant", "destruction", "present"]
ES5 => 数组的处理 Array.prototype.map()
代码:
var array1 = [1, 4, 9, 16]; // pass a function to map
const map1 = array1.map(x => x * 2); console.log(map1);
// expected output: Array [2, 8, 18, 32]
最新文章
- 从零开始山寨Caffe·壹:仰望星空与脚踏实地
- virtual方法和abstract方法
- debian7.1 sources.list
- Java for LeetCode 166 Fraction to Recurring Decimal
- hdu----(1847)Good Luck in CET-4 Everybody!(简单巴什博奕)
- 获取其它进程窗口中的状态栏信息(FindWindowEx GetWindowThreadProcessId OpenProcess SendMessage轮番轰炸)
- img超出div width时, jQuery动态改变图片显示大小
- zoj 1539 Lot
- Android替换APP字体 — Typeface
- 《算法导论》Chapter 4 Divide-and-Conquer的学习笔记
- C++ 中的sort()排序函数用法
- Java基于opencv—归一化
- The component and implementation of a basic gradient descent in python
- centos 7.5安装docker-CE 18
- FFmpeg使用基础
- 转换类型 totypeString
- 牛客网-湘潭大学校赛重现H题 (线段树 染色问题)
- np.tile 函数使用
- 洛谷P2777 [AHOI2016初中组]自行车比赛
- java 多线程之:join() 方法