当前位置:网站首页>ES6 grammar summary -- Part I (basic)
ES6 grammar summary -- Part I (basic)
2022-07-06 12:07:00 【Aboci Bang】
Variable let
1. There are block level scopes : Variables do not pollute the global scope in the block level scope .
2. There is no claim to promote : Variables can only be used after declaration .
3. Does not affect the scope chain : Variables are normally used in the scope chain .
Constant const
1. The initial value should be assigned when declaring .
2. Constants are generally capitalized .
3. The value of a constant cannot be modified .
4. There are block level scopes .
5. Modifying sub elements of array and object elements is not a constant modification ( Because the address corresponding to the constant has not changed ).
Deconstruct assignment -- Extract values from arrays and objects and assign them to variables
Simple structure
An array of deconstruction :
Object to deconstruct : notes : Variables declared during deconstruction must exist in the object , Deconstruction can be ignored object key The order of ( Put variables a,b Changing positions can also be deconstructed normally )
Complex structure
Complex structure of objects :
names :
Template string A pair of backquotes Support output line wrapping
For variable splicing
be used for dom Splicing
Object simplification -- If the property name and property value in the object are the same , Can simplify writing
Omit attribute values
Omit anonymous functions
Arrow function =>
How to write it
this
this It refers to the scope of the function declaration and will not be changed .
Arrowhead function this
Of a normal function this
Be careful :
1. Arrow functions cannot be instantiated as construction objects
2. Out of commission arguments Variable
The usage scenarios of arrow function
Apply to : And this Unrelated callbacks , Such as : Timer 、 Array methods
Do not apply to : Event callback ( because this Incorrect pointing )、 Object to declare methods
Parameter default
It is customary to write formal parameters with initial values at the end
The basic way of writing
Combined deconstruction assignment And initial value
rest Parameters Get function arguments
notes :...args
Put it at the end of the parameter
Expand operator ( Extension operator ) Convert the array to a comma separated string
Application scenarios
1. Array merge
2. Array Clone -- Deep copy
3. Pseudo array to array (dom object 、arguments etc. )
Technical references :b standing – 【 Silicon Valley 】 I recommend it
https://www.bilibili.com/video/BV1uK411H7on?p=1&vd
边栏推荐
- ESP learning problem record
- imgcat使用心得
- Characteristics, task status and startup of UCOS III
- RuntimeError: cuDNN error: CUDNN_STATUS_NOT_INITIALIZED
- Matlab learning and actual combat notes
- Oppo vooc fast charging circuit and protocol
- RT-Thread的main线程“卡死”的一种可能原因及解决方案
- Reno7 60W super flash charging architecture
- [esp32 learning-1] construction of Arduino esp32 development environment
- FTP file upload file implementation, regularly scan folders to upload files in the specified format to the server, C language to realize FTP file upload details and code case implementation
猜你喜欢
机器学习--线性回归(sklearn)
Kconfig Kbuild
Kconfig Kbuild
高通&MTK&麒麟 手机平台USB3.0方案对比
Cannot change version of project facet Dynamic Web Module to 2.3.
Pytorch four commonly used optimizer tests
JS正则表达式基础知识学习
[esp32 learning-1] construction of Arduino esp32 development environment
IOT system framework learning
Kaggle competition two Sigma connect: rental listing inquiries (xgboost)
随机推荐
Unit test - unittest framework
FreeRTOS 任务函数里面的死循环
ESP learning problem record
Raspberry pie tap switch button to use
锂电池基础知识
Kaggle竞赛-Two Sigma Connect: Rental Listing Inquiries
共用体(union)详解【C语言】
AMBA、AHB、APB、AXI的理解
Rough analysis of map file
FTP file upload file implementation, regularly scan folders to upload files in the specified format to the server, C language to realize FTP file upload details and code case implementation
open-mmlab labelImg mmdetection
Oppo vooc fast charging circuit and protocol
Using LinkedHashMap to realize the caching of an LRU algorithm
[esp32 learning-2] esp32 address mapping
使用LinkedHashMap实现一个LRU算法的缓存
JS变量类型以及常用类型转换
Vert. x: A simple login access demo (simple use of router)
Comparaison des solutions pour la plate - forme mobile Qualcomm & MTK & Kirin USB 3.0
Kaggle competition two Sigma connect: rental listing inquiries (xgboost)
电商数据分析--用户行为分析