How to declare variables with the keyword let in es6
Editor to share with you how to use the keyword let to declare variables in es6, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Declare variables with the keyword let
Let a; / / undefinedlet b = 1; function add (b) {let sum = b + 1; return sum;} let c = add (b)
"javascript strict mode" is required: 'use strict'
There is no variable promotion.
Repetition is not allowed.
The variable scope declared by let is in the block-level domain. After using let definition inside the function, it has no effect on the outside of the function (block-level scope).
You can assign a value to a variable when you declare it, with a default value of undefined, or you can assign a value to the variable later in the script, which cannot be used before life (temporary dead zone)
The above is all the content of the article "how to declare variables with the keyword let in es6". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!