Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • JS Tutorial
  • JS Exercise
  • JS Interview Questions
  • JS Array
  • JS String
  • JS Object
  • JS Operator
  • JS Date
  • JS Error
  • JS Projects
  • JS Set
  • JS Map
  • JS RegExp
  • JS Math
  • JS Number
  • JS Boolean
  • JS Examples
  • JS Free JS Course
  • JS A to Z Guide
  • JS Formatter
Open In App
Next Article:
ECMAScript 2021 (JS 2021/2022)
Next article icon

JS 2020 - ECMAScript 2020

Last Updated : 24 Aug, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

JavaScript ECMAScript 2020 (ES11) introduced new features like optional chaining, nullish coalescing, dynamic import(), BigInt, and Promise.allSettled(), etc. enhancing language capabilities for modern web development needs.

JavaScript 2020 (ES11) or ECMAScript 2020 new features are:

BigInt

type for arbitrary precision integers beyond the Number's limit.

String matchAll()

returns an iterator for all regex matches in the string.

The Nullish Coalescing Operator (??)

returning right operand if the left is nullish, else left.

The Optional Chaining Operator (?.)

accessing nested properties if they exist, otherwise returns undefined.

Logical AND Assignment Operator (&&=)

assigns the right operand to the left if the left is truthy.

Logical OR Assignment (||=)

assigns the right operand if the left is falsy, else left.

Nullish Coalescing Assignment (??=)

the operator assigns the right operand if the left is nullish, else left.

Promise allSettled()

returning an array of promise results with status and value.

Dynamic Import

enables asynchronous import of modules at runtime.

Method 1: BigInt

BigInt is a built-in object in JavaScript that provides a way to represent whole numbers larger than 253-1.

 

Syntax:

BigInt( number )   or  Appending n to end of an integer literal  

Example: Here is the basic example of above-method.

JavaScript
// Parameter in decimal format let bigNum = BigInt(     "123422222222222222222222222222222222222"); console.log(bigNum);  // Parameter in hexadecimal format let bigHex = BigInt("0x1ffffffeeeeeeeeef"); console.log(bigHex);  // Parameter in binary format let bigBin = BigInt(     "0b1010101001010101001111111111111111"); console.log(bigBin); 

Output
123422222222222222222222222222222222222n  36893488074118328047n  11430854655n

Method 2: String matchAll() Method

This method returns an iterator of all matches in a string based on a regular expression, facilitating comprehensive pattern matching and data extraction in JavaScript.

Syntax:

str.matchAll(Regexp)  

Example: Here the basic example of above-mentioned method.

JavaScript
function myFunction() {      //Regular expression with the /g flag     const regex = /e(xam)(ple(\d?))/g;     //Reference string     const str = 'example1example2example3';      //Using matchAll() method     const array = [...str.matchAll(regex)];      console.log(array[0]); } myFunction(); 

Output
[    'example1',    'xam',    'ple1',    '1',    index: 0,    input: 'example1example2example3',    groups: undefined  ]

Method 3: The Nullish Coalescing Operator (??)

The nullish coalescing operator (??) returns the right operand if the left operand is null or undefined, otherwise, it returns the left operand, enhancing conditional value assignment in JavaScript.

Syntax:

variable ?? default_value  

Example: In this example, we will see a basic function using the nullish coalescing operator.

JavaScript
function myFunction(bar) {     bar = bar ?? 55;     console.log(bar); } myFunction(); myFunction(22);  

Output
55  22

Method 4: The Optional Chaining Operator (?.)

The optional chaining operator (?.) allows safe accessing of nested properties and methods in JavaScript objects, preventing errors when properties are undefined or null.

Syntax:

let Value = user.dog && user.dog.name;  

Example: In this example we are using the above-explained method.

JavaScript
const user = {     id: {         name: "Rohit"     } };  console.log(user.cat?.name); console.log(user.id?.name); console.log(user.cat.name); 

Output:

"Rohit"  "error"  "TypeError: Cannot read properties of undefined (reading 'name')  

Method 5: Logical AND Assignment Operator (&&=)

The logical AND assignment operator (&&=) assigns the right operand to the left operand if the left operand is truthy; otherwise, it retains the left operand value in JavaScript.

Syntax:

x &&= y    

is equivalent to

x && (x = y)  

Example: This example shows the basic use of the Javascript Logical AND assignment(&&=) operator.

JavaScript
let x = 5; let y = 10;  // Changing the value using logical // AND assignment operator x &&= y; console.log(x);  let name = {     firstName: "Ram", };  console.log(name.firstName);  // Changing the value using logical // AND assignment operator name.firstName &&= "Shyam";  // Here the value changed because // name.firstName is truthy console.log(name.firstName); 

Output
10  Ram  Shyam

Method 6: Logical OR Assignment (||=)

The logical OR assignment operator (||=) assigns the right operand to the left operand if the left operand is falsy; otherwise, it retains the left operand value in JavaScript.

Syntax:

x ||= y  

is equivalent to

x || (x = y)  

Example: Here is the example above-mentioned method.

JavaScript
let name = {     firstName: "Virat",     lastName: "", }; // Output: Virat console.log(name.firstName);  name.firstName ||= "Shyam"; // Output: Virat (unchanged, because it's truthy) console.log(name.firstName); // Output: (empty string) console.log(name.lastName);  name.lastName ||= "Kohli"; // Output: Kohli (changed, because it's falsy) console.log(name.lastName); 

Output
Virat  Virat    Kohli

Method 7: Nullish Coalescing Assignment (??=)

The nullish coalescing assignment operator (??=) assigns the right operand to the left operand if the left operand is nullish (null or undefined); otherwise, it retains the left operand value.

Syntax:

x ??= y  // Means : x ?? (x = y)  

Example: Here is the basic example of above-mentioned methods

JavaScript
let x = 12; let y = null;  let z = 13;  // The value of x will become // unchanged because x is not nullish. x ??= z;  // The value of y will be // changed because y is nullish. y ??= z;   console.log(x) // 12 console.log(y) // 13 

Output
12  13

Method 8: Promise allSettled()

Promise.allSettled() returns an array of promise results, each containing a status (fulfilled or rejected) and the resolved value or rejection reason, facilitating comprehensive promise handling.

Syntax:

Promise.allSettled(iterable);  

Example: In this example, we will use Promise allSettled() Method.

JavaScript
// Illustration of Promise.allSettled() // Method in Javascript with Example  const p1 = Promise.resolve(50); const p2 = new Promise((resolve, reject) =>     setTimeout(reject, 100, 'geek')); const prm = [p1, p2];  Promise.allSettled(prm).     then((results) => results.forEach((result) =>         console.log(result.status, result.value))); 

Output
fulfilled 50  rejected undefined

Supported browser:

  • Chrome 1
  • Edge 12
  • Firefox 1
  • Safari 1
  • Opera 3

Next Article
ECMAScript 2021 (JS 2021/2022)

V

vishalkumar2204
Improve
Article Tags :
  • JavaScript
  • Web Technologies
  • javascript-basics

Similar Reads

  • JavaScript ES5 (JS 2009)
    JavaScript 2009 (ES5) refers to the fifth edition of the ECMAScript language specification, standardized in 2009. It introduced several features, like strict mode, new methods, JSON support, and improved syntax for better programming practices and compatibility across browsers. ECMAScript 5 (ES5) in
    7 min read
  • ES2015: Latest Version of JavaScript
    ES2015 is the latest version of JavaScript programming language. It is the first major upgrade to JavaScript since 1997. It was approved in June 2015 by ECMA international, an association responsible for approving ECMA standards which programming languages like JavaScript, CoffeeScript and TypeScrip
    4 min read
  • JS 2015 or ECMAScript 6 (ES6)
    JS 2015 (ES6) also known as ECMAScript 6 (ES6), ECMAScript 6 (ES6) is a significant update to JavaScript, introducing arrow functions, classes, template literals, let and const for variable declaration, enhanced object literals, destructuring, and more modern features for better code organization an
    10 min read
  • JS 2016 or ECMAScript 2016
    JavaScript 2016 (ES2016) is a modified version of ES2015 in which they introduced some new features like JavaScript Exponentiation (**) operator, JavaScript Exponentiation assignment (**=), and Array..includes() method for array element presence checking, enhancing calculations, and array operations
    2 min read
  • JS 2017 - ECMAScript 2017
    JavaScript (JS) 2017, or ECMAScript 2017, introduced some new features in JavaScript. It enhanced asynchronous programming with async functions, provided shared memory and atomics for improved concurrency, and introduced Object.values() and Object.entries() for streamlined object manipulation. These
    3 min read
  • JS 2018 - ECMAScript 2018
    JavaScript 2018 (ES9) or ECMAScript 2018 is a modified version of ES8, in which ES9 introduced new features like asynchronous iteration, rest/spread properties, and enhancements to regular expressions, further improving asynchronous programming, object manipulation, and string handling capabilities.
    4 min read
  • JS 2019 - ECMAScript 2019
    ECMAScript 2019, also known as ES10, introduced features like Array.flat(), Array.flatMap(), Object.fromEntries(), and Symbol. description, and some string methods, for enhancing JavaScript's capabilities and expressiveness. JavaScript 2019 (ES10) or ECMAScript 2019 new features are: Name Descriptio
    5 min read
  • JS 2020 - ECMAScript 2020
    JavaScript ECMAScript 2020 (ES11) introduced new features like optional chaining, nullish coalescing, dynamic import(), BigInt, and Promise.allSettled(), etc. enhancing language capabilities for modern web development needs. JavaScript 2020 (ES11) or ECMAScript 2020 new features are: BigInttype for
    5 min read
  • ECMAScript 2021 (JS 2021/2022)
    JavaScript in 2021/2022 continues to evolve, with ES2021/ES2022 bringing enhanced features like private class fields, promise improvements, and record data structures, boosting developer productivity and code quality. JavaScript New Features in ES2021Name Description Promise any(): Resolves if any P
    4 min read
  • New Features in ECMAScript 2021 Update
    ECMAScript is a part of JavaScript language which is mostly used in web technology, building websites, or web apps. ECMAScript is growing as one of the world's most widely used general-purpose programming languages. It is majorly used in embedding with web browsers and is also adopted for server and
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences