JavaScript ES 2020

JavaScript ES 2020

Anirudh Panda
ยทJan 11, 2021ยท

3 min read

Subscribe to my newsletter and never miss my upcoming articles

1- ๐—ก๐˜‚๐—น๐—น๐—ถ๐˜€๐—ต ๐—ฐ๐—ผ๐—ฎ๐—น๐—ฒ๐˜€๐—ฐ๐—ถ๐—ป๐—ด ๐—ผ๐—ฝ๐—ฒ๐—ฟ๐—ฎ๐˜๐—ผ๐—ฟ (??) accepts two operands and return the right operand if the left one is null or undefined.

console.log(false ?? 'hellooo') //false
console.log(null ?? 'hellooo') //'hellooo'
console.log(null || 'hellooo') //'hellooo'
console.log((false || null) ?? 'hellooo') // 'hellooo'
console.log(null ?? (false || 'hellooo')) // 'hellooo'

2- ๐—ข๐—ฝ๐˜๐—ถ๐—ผ๐—ป๐—ฎ๐—น ๐—ฐ๐—ต๐—ฎ๐—ถ๐—ป๐—ถ๐—ป๐—ด ๐—ผ๐—ฝ๐—ฒ๐—ฟ๐—ฎ๐˜๐—ผ๐—ฟ (?.) Simplify the way to access a property located deep within a chain of connected objects. Eg: Pokemon && Pokemon.raichu can be written as Pokemon?.raichu

3- ๐—ฃ๐—ฟ๐—ผ๐—บ๐—ถ๐˜€๐—ฒ.๐—ฎ๐—น๐—น๐—ฆ๐—ฒ๐˜๐˜๐—น๐—ฒ๐—ฑ() accepts a list of promises and returns a new promise that resolves to an array of values, which were settled (either resolved or rejected) by the input promises.

4- ๐——๐˜†๐—ป๐—ฎ๐—บ๐—ถ๐—ฐ ๐—œ๐—บ๐—ฝ๐—ผ๐—ฟ๐˜ - The import allows you to dynamically import a module when needed. The import() returns a Promise that will be fulfilled once the module is loaded completely.

5- ๐—•๐—ถ๐—ด๐—œ๐—ป๐˜ a new primitive type that can represent whole numbers bigger than 2^53 - 1, which is the largest number Javascript can reliably represent with the Number type. To make a BigInt, you append ๐’ to the end of an integer literal.

3 + 4 + 1n // ERROR! as BigInts need to be calculated with other BigInts.
3n + 4n + 1n //  8n
3 + 4 + 1 //  8 
// Both produce the value of 8, but one is a Number type, the other is a BigInt type

6- ๐—ด๐—น๐—ผ๐—ฏ๐—ฎ๐—น๐—ง๐—ต๐—ถ๐˜€ - If you write code that needs to access the global object, use different syntaxes like window, frames, self, or global. To standardize this, ES2020 introduced the globalThis available across environments.

That's all, folks.
Happy Hustling!

Did you find this article valuable?

Support Anirudh Panda by becoming a sponsor. Any amount is appreciated!

See recent sponsors |ย Learn more about Hashnode Sponsors
Share this