当前位置:网站首页>ES6 from getting started to mastering 05: extended operators and arrow functions of functions
ES6 from getting started to mastering 05: extended operators and arrow functions of functions
2022-07-22 05:31:00 【Kai Xiaomo】
explain
ES6 From entry to Mastery Series ( whole 23 speak ) Learning notes .
Extension operator
- Remainder operator : Combine multiple independent parameters into an array
- Extension operator : Split an array , And pass each item as a separate parameter to the function
es5 utilize apply Maximize the array
const arr = [1,2,3,4,66,8,9];
const maxNum = Math.max.apply(null, arr);
console.log(maxNum);
es6 Use the expansion operator to maximize the array
const arr = [1,2,3,4,66,8,9];
const maxNum = Math.max(...arr);
console.log(maxNum);
Arrow function
Use =>
To define ,function(){}
be equal to () => {}
let add = function (a, b) {
return a + b;
}
let add2 = (a, b) => {
return a + b;
}
let add3 = (a, b) => a + b;
console.log(add(1, 2));
console.log(add2(1, 2));
console.log(add3(1, 2));
Returns the object :
let getObj = (val) => {
return {
name: "kaimo",
value: val
};
}
let getObj2 = (val) => ({
name: "kaimo", value: val});
console.log(getObj(313));
console.log(getObj2(666));
Closure function :
let fn = (function() {
return function() {
console.log("hello es6");
}
})();
let fn2 = (() => {
return () => {
console.log("hello es6 2");
}
})();
console.log(fn());
console.log(fn2());
边栏推荐
- LeetCode·每日一題·814.二叉樹剪枝·遞歸
- ES6 从入门到精通 # 05:函数之扩展运算符、箭头函数
- C language student achievement management system
- Tensorflow introductory tutorial (XXXIII) -- image segmentation loss function focalloss
- Pl marker (ACL 2022) - extraction de l'information (ner + re) Nouvelle Sota, analyse de thèse et navigation de code
- Using symbol, ES6 is a new method to obtain key value
- BraTS18——多模态MR图像脑肿瘤分割挑战赛续
- Leetcode · daily question · 814 Binary tree pruning recursion
- 表情包小程序,副业日入400+
- [book club No. 13] + Chapter II packaging format of video files
猜你喜欢
GTSAM入门学习
Solution of access denied for user 'root' @ 'localhost' (using password: yes)
HTTP缓存策略,强缓存,协商缓存
PL-Marker(ACL 2022)——信息抽取(NER+RE)新SOTA,论文浅析与代码浏览
[并发编程基础]-集合的线程安全
虚拟机无法连接互联网
Unity URP forward rendering process and obtaining screen space UVs and depth
Win11如何增强麦克风?Win11增强麦克风的设置
unity URP前向渲染流程以及获取屏幕空间UV和深度
The landing of tdengine in the GPS and AIS scheduling of Zhongtian steel
随机推荐
[300 + selected interview questions from big companies continued to share] big data operation and maintenance sharp knife interview question column (6)
虚拟机无法连接互联网
814. 二叉树剪枝 : 简单递归运用题
从单体架构到分布式架构,有哪些坑?
请写一个函数,将列表中所有字符串类型元素中的'abc'替换为'BCD'【杭州多测师】【杭州多测师_王sir】...
What if MySQL deletion fails
牛客刷题篇
【微信小程序】WXSS和全局、页面配置入门砖
Windows cannot start the mysql80 service (located on the local computer)
2022.7.9暑假个人训练1-C . Clean up the Powers that Be
“全光”时代的宠儿——400G光模块
Leetcode-153- find the minimum value in the rotation sort array
mysql 库、表增删改
如何绘制PCB外形加工图
The installation package cannot be downloaded due to the mismatch when PIP downloads the package: error: subprocess exited with error; error: metadata-generation-failed;
LeetCode·
[basis of concurrent programming] - thread safety of collections
面试突击66:请求转发和请求重定向有什么区别?
全面败退,中国手机首次遭受重大挫折,三星和苹果则大幅增长
PL-Marker(ACL 2022)——信息抽取(NER+RE)新SOTA,论文浅析与代码浏览