ES6 Notes
ES6 Notes
- Variables declared with -let- are limited to the scope of the function
where they were declared
2. Arrow function
- If you only have one argument, you don't need to use paranthases,
and if you only have one line of code for the function instructions,
you don't need the {} or the return keyword
3. Default parameters
- You can set a default parameter in case that it isn't passed to the
functinon
4. Rest operator
- The rest operator lets you create a function, that takes any number of
arguments
- Syntax : function sum(...) {} // Now I can call this function with any
number of arguments
5. Spread operator
- You can use it to copy an array to another array, in order to transfer the
content, not the reffrence
- Example : arr2 = [...arr1]
6. Destructuring
- You can also use destructuring to asssign variables values from nested
objects
- You can use it together with the rest operator, to reassign array
elements, ex: const[ , , ...arr] = oldArray;
7. Template literals
- Same as in Java
- Constructor keyword
- You can use the import and export keywords, to share data between files
11. Promises