Using // for 1 line comment, /* */ for multi-line comments
JS can be execute without ; but it’s minified need to be ;
Variable and function name are case sensitive
Variables/functions should be names with format camel case (nameOfVariable)
Name a constant: const FAV_PET = 'Cat'
UpperCamelCase should be used by conversion for ES6 class names.
Using \ for special characters, for example \" for " inside double quote
Practice directly on the browser
Open the browser (I use Brave), press F12 to open Inspect window, then choose tab Console. Now you can practice on this console window, for example, try with console.log("Hello World") end press Enter
ES6
“ES” = “ECMScript” ~ “Javascript”
Most of browser use ES6 but not all
ES6 = ES2015
New feature: Arrow Function, Classes, Modules, Promise, Generator, let and const
Read more about ES on w3schools.
Concise things
Getters and setters
Export/Import to share code blocks
Declare variables & scope
Difference between var, let, const
Multi-column
var scope
let scope
Multi-column
const scope
const scope
Output
Special operators
|| vs ??
|| check false values
?? check null or undefined
async, await, promise
You don’t need use try/catch in every async/await. You only need to do it at the top level
Sync vs Async
Sync
In synchronous programming, operations are performed one after the other, in sequence. Each line of code needs to wait for the previous one to finish before proceeding to the next.
Async
Asynchronous programming, on the other hand, allow multiple tasks to run independently of each other. A task can be initiated and while waiting for it to complete, other tasks can proceed.
Time difference Promise all && async...await
Note: If there is no data dependency you should use Promise.all