Function and the cords
Note: The default value of manually passing undefined also takes effect
The difference between function declarations and function expressions
Function declaration
function sayHi(name) { console.log(name) }
Copy the code
Functional expression
let sayHi = function sayHi(name) { console.log(name) }
Copy the code
The difference between
Function declarations globally available function expressions are created only when the code executes to them and are called only after creationCopy the code
The UI interaction
Null-value merge operator (??)
Null-value merge operator (??) Is a logical operator that returns the right-hand operand if the left-hand operand is null or undefined, otherwise returns the left-hand operand. Are still a little difference, and | | see example (console Google browser does not support??
const a = 0 || 1 // a=1
const a = 0 ?? 1 // a=0
const a = '' || 1 // a=1
const a = '' ?? 1 // a=''
Copy the code