当前位置:网站首页>ES6的详细注解
ES6的详细注解
2022-07-02 05:54:00 【Serena_tz】
let
- 声明变量的新方法。
- 变量无法重复声明。
- 块级作用域。也就是说let只在代码块中生效,包括if、else等花括号中的变量不会定义到全局。
- 不存在变量提升。也就是说,在声明变量之前使用变量会报错。
- 不影响作用域链效果。也就是,在函数中往上找变量,函数外面由let定义的变量,仍然能找到。

用let实现循环遍历。这是因为只在块级作用域中生效。
const
用来声明一个常量,值没有办法被修改的。
- 一定要赋初始值。
- 一般常量使用大写(潜规则)
- 常量的值没有办法被修改。
- 块级作用域
- 对于数组和对象的元素修改,不算对常量进行修改,不会报错。(因为指向的地址并未发生改变)
变量的解构赋值
用一定的模式从数组和对象中提取值。
数组的解构

对象的解构

模板字符串
`我也是一个字符串哦~`
- 内容中可以直接出现换行符
- 变量拼接,使用
${}
对象的简化写法
属性名和属性值相同可以只写一个。
函数也可以直接写。
箭头函数


箭头函数中的this是静态的,始终指向声明函数时所在作用域下的this值。
不能作为构造化实例对象

不能使用arguments变量

箭头函数的简写


函数参数的默认值
传了参数我们就使用传入的参数,没有传入实参,我们就使用默认值。

默认值可以与解构赋值一起使用。
也可以传入默认值。
rest参数
rest必须放到参数的最后。输出的是一个数组。

扩展运算符


Symbol
Symbol简单介绍



数据类型的总结:
利用Symbol给对象添加属性
给对象添加属性的时候我们不用担心命名冲突的问题。

Symbol内置值
自己来控制类型检测。
控制值是否可以展开。
扩展对象的功能~~
迭代器




for of遍历的键值,for in遍历的键名

生成器
生成器是一个特殊的函数,异步函数,纯回调函数。yield算作函数代码的切割符,每次用函数next()来执行代码。
for of遍历出来的是value。

生成器函数的参数
传入参数就会作为执行一次代码的返回值。
promise
边栏推荐
- 数据库学习总结5
- 【C语言】筛选法求素数
- 2022-2-14 learning xiangniuke project - section 23, section 5, development login and exit functions
- 500. 键盘行
- 数据挖掘方向研究生常用网站
- Yyds dry inventory what is test driven development
- [leetcode] day92 container with the most water
- Summary of MySQL constraints
- memcached安装
- 【论文翻译】GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond
猜你喜欢

2022-2-14 learning xiangniuke project - Section 7 account setting

How to write good code - Defensive Programming Guide

idea開發工具常用的插件合集匯總

Technologists talk about open source: This is not just using love to generate electricity

Balsamiq wireframes free installation

How vite is compatible with lower version browsers

3D 打印机 G 代码命令:完整列表和教程

Cube magique infini "simple"

Lantern Festival gift - plant vs zombie game (realized by Matlab)

Matplotlib double Y axis + adjust legend position
随机推荐
Mathematical statistics and machine learning
3D printer G code command: complete list and tutorial
Summary of MySQL constraints
Minimum value ruler method for the length of continuous subsequences whose sum is not less than s
Web页面用户分步操作引导插件driver.js
Zzuli:1066 character classification statistics
[leetcode] day92 container with the most water
运动健身的一些心得经验
JS determines whether the mobile terminal or the PC terminal
token过期自动续费方案和实现
How to write good code - Defensive Programming Guide
Appnuim environment configuration and basic knowledge
PHP extensions
How vite is compatible with lower version browsers
Fundamentals of software testing
Here comes a new chapter in the series of data conversion when exporting with easyexcel!
“簡單”的無限魔方
PHP obtains some values in the string according to the specified characters, and reorganizes the remaining strings into a new array
Lingyunguang rushes to the scientific innovation board: the annual accounts receivable reaches 800million. Dachen and Xiaomi are shareholders
Zzuli:1067 faulty odometer