The Modern Javascript
- Types
- Use “null” to write an “empty” or an “unknown” value into the variable
- “undefined” is only used for checks, to see if the variable is assigned or not
- The meaning of undefined is “value is not assigned”
- If a variable is declared, but not assigned, then its value is exactly undefined
- Functions
- Callback functions
- Function Declaration and Function Expression
- Arrow Functions
[js]let sum = (a, b) => a + b;
alert( sum(1, 2) ); // 3[/js]This equals to
[js]let sum = function(a, b) {
return a + b;
};[/js]- Multiline Arrow Functions
[js]let sum = (a, b) => { // the figure bracket opens a multiline function
let result = a + b;
return result; // if we use figure brackets, must use return
};alert( sum(1, 2) ); // 3
[/js]
- Multiline Arrow Functions
Leave a Reply