JavaScript ES6 / ES2015 - My Notes
Using ES6 in Prod
- Supported by modern but not by older browsers
- So, ES6 needs to be transpiled or multipiled in prod
The let and const
const- generates an error when attempted to change value- both - block-scoped while
varwas function scoped (a block is just{...}) - Now, instead of using IIFE, we can use a block. Variables (and function expressions assigned to variables) marked
constorletwill be private. While those marked withvarwill be public.
Strings
- Template liters (note back-ticks):
His name is ${firstName} ${lastName}.
Arrow Functions
- If we have an array arr1, then
arr1.map(el => 2 * el)will return an array of doubled numbers. - In fuller format:
arr1.map((elem, index) => { .... return ... }) - Arrow functions don't have their own
this. They use thethisof the function they written in - it's called lexical this.

No comments:
Post a Comment