1. First match webpack and ES6 syntax.
2.let and Const:let define local variables (only valid within scope), const defines global (uniqueness)
3.es6 's Arrow function
Let Kitty = {
Age:1,
Grow:function () {
SetTimeout (() =>{
Console.log (This.age);
},1000);
}
}
Kitty.grow ();
4.Rest parameters
When the last parameter of a function is prefixed with "...", he becomes an array of arguments.
Function test (.... args) {
Console.log (args)
}
Test (+/-)
function test2 (name, ... args) {
Console.log (args)
}
Test2 (' Peter ', 2, 3)
Results [2,3]
For array data processing
Es5
var = [arr1];
var arr2 = [4,5,6];
var arr3 = Arr1.concat (ARR2);
Console.log (ARR3)
Using the expand operator
Let Arra = [n/a];
Let ARRB = [4,5,6];
Let ARRC = [... arra,... ARRB];
Console.log (ARRC)
For an object
Let Tom = {name: ' Tom ', Age: ' 18 '}
Tom = {... tom,sex: ' Boy '}
Console.log (Tom)
Template string, ES6 optimization, mainly with "'" This symbol
Let name = ' Jack ';
Let a = ' my name is ${name}! ';
Console.log (a)
React.js Beginner's Notes