JavaScript - AnxinYang/Cheat-Sheet GitHub Wiki
New Features in 2020
Dynamic Import
async function loadLib(){
const lib = await import('some lib');
}
Optional Chainning
let item = data?.prop?.['something'] // no error when data is undefined
Nullish Coalescing
...
const number = value ?? 400 // assign 400 to number if value is null or undefined
...
Big Int
const largeNum = BigInt(some big number);
const superLarge = largeNumber ** 23n
CSS
Ticks
Fake Scrollspy: Code
HTML
Lazy loading
<img loading="lazy" />