You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 19, 2024. It is now read-only.
x=>x+1// similar to function(x) {return x + 1;}(x,y)=>x+y// similar to function(x, y) {return x + y;}x=>{returnx+1}
Array destructuring
var[x,,y]=[1,2,3];// x === 1, y === 3var[x]=[];// x === undefinedvar[x=1]=[];// x === 1 (default value)var[x,y,z]="xyz";// x === "x", y === "y", z === undefinedvar[a, ...b]=[1,2,3];// a === 1, b === [2, 3]var[a, ...b]=[1];// a === 1, b === []
Object destructuring
var{x,a:y, z}={x: 1,y: 2};// x === 1, a === 2, z === undefined
Default function parameters
function(a=1,b=2){...}function(a,b=a){...}// default can be previous param
Rest parameters
function(a, ...b){...}// b will be an array containing the 2nd and above params
Template strings
varx=1,y='hello';`${y}! x + 1 = ${x+1}`// === "hello! x + 1 = 2"