E
E
ES6+ for React
Search…
E
E
ES6+ for React
Introduction
Introduction
Introduction
Statements and declarations
let
const
class
import
export
Standard built-in objects
Arrow functions
Template literals
Array.prototype.map()
Computed property names
Expressions and operators
Spread operator
Destructuring assignment
Logical Operators
Powered By
GitBook
let
Defination
The let statement declares a block scope local variable, optionally initializing it to a value.
Syntax
1
let
var1
[
=
value1
]
[,
var2
[
=
value2
]]
[,
...
,
varN
[
=
valueN
]];
Copied!
Examples
1
function
varTest
()
{
2
var
x
=
1
;
3
if
(
true
)
{
4
var
x
=
2
;
// same variable!
5
console
.
log
(
x
);
// 2
6
}
7
console
.
log
(
x
);
// 2
8
}
9
10
function
letTest
()
{
11
let
x
=
1
;
12
if
(
true
)
{
13
let
x
=
2
;
// different variable
14
console
.
log
(
x
);
// 2
15
}
16
console
.
log
(
x
);
// 1
17
}
Copied!
Usage
1
function
Title
(
props
)
{
2
let
content
=
props
.
content
3
return
(
4
<
h1
>
{
content
}
</
h1
>
5
)
6
}
Copied!
References
MDN let
Introduction - Previous
Introduction
Next - Statements and declarations
const
Last modified
2yr ago
Copy link
Contents
Defination
Syntax
Examples
Usage
References