当前位置:网站首页>ES6新特性
ES6新特性
2022-06-12 14:43:00 【luemeon】
箭头函数
相当于匿名函数
- 箭头函数本身没有作用域(无this)
- 箭头函数的this指向上一层,上下文决定其this
- 基本语法:参数 => 函数体
- 箭头函数体中的 this 对象,是定义函数时的对象,而不是使用函数时的对象。在函数定义的时候就已经决定了
() => return 'hello'
(a, b) => a + b
(a) => {
a = a + 1
return a
}ES6新特性箭头函数语法、如何正确使用箭头函数_Hayley2016的博客-CSDN博客_箭头函数
`${}`
反单引号(``)完成拼接字符串而不是单引号(‘’)
let str=`I love ${a}, because he is handsome.`;let:ES6新增,用于声明变量,有块级作用域
let [a, b, c] = [1, 2, 3];
// a = 1,b = 2,c = 3 相当于重新定义了变量a,b,c,取值也更加方便
// , = 占位符
let arr = ["小明", "小花", "小鱼", "小猪"];
let [,,one] = arr; // 这里会取到小鱼
// 解构整个数组
let strArr = [...arr];
// 得到整个数组
console.log(strArr);
- 解构赋值是对赋值运算符的扩展
- 针对数组或者对象进行模式匹配,然后对其中的变量进行赋值
- 都2021年了,再不学ES6你就out了 —— 一文搞懂ES6_欧阳呀的博客-CSDN博客
边栏推荐
- 亿纬锂能拟募资90亿:刘金成骆锦红夫妇合计认购60亿 布局光谷
- Nesting of C language annotations
- Location (I) error: command erred out with exit status
- 阿里建议所有 POJO 类属性使用包装类,但这些坑你有注意到吗?
- 程序构造和解释之过程抽象
- [Writeup]BUU SQL COURSE1[入门级]
- C secret script Chapter 3 (detailed explanation of string function) (Section 2)
- 华为设备配置H虚拟专用网
- 【Instant】1. Equivalent to date class 2 Represents a moment
- Jenkins' RPC test project
猜你喜欢
随机推荐
[wechat applet] 2 Environmental preparation
C 字符串
Introduction to QT reflection mechanism and signal slot mechanism
【SimpleDateFormat】1. Conversion of date type and text type 2 Thread unsafe
C secret script Chapter 3 (detailed explanation of string function) (Section 2)
Easygui query the company name in the document
Writing method of JUnit multithreading
Producers (send syncask requests) and consumers (with xxxask monitoring and Implementation)
Recursive summary of learning function
String concatenation and ternary operators
And, or, not equal, operator
Nesting of C language annotations
Two methods of QT using threads
Two methods of implementing asynchronous calling function with QT
Webdriver opens in full screen and a prompt "Chrome is under the control of automatic test software" appears in Chrome
掌门教育被强制退市:上市仅一年时间 软银CMC损失惨重
C main函数
Autofac浅学(2)
C 转义字符
C常量,不能改变





![[Writeup]BUU SQL COURSE1[入门级]](/img/eb/1b2541b04ca231cb07f1f3706f51c7.png)



