← Back to list

Amazing Features of ES13

ECMAScript 2015 (ES6) brought many new features to JavaScript, and subsequent versions have continued to build on that foundation…

Prabhjot Singh · 2023-05-06 15:37 · 1 claps · 2.3 min read
#javascript #es13 #features #technology #programming-languages
Open on Medium ↗
Wiki topics: 💻 · Programming 🌐 · Web Development

Amazing Features of ES13

ECMAScript 2015 (ES6) brought many new features to JavaScript, and subsequent versions have continued to build on that foundation. ECMAScript 2015 introduced a number of new language features, including classes, arrow functions, and template literals. Since then, there have been a number of new features introduced with each new release of ECMAScript. In this blog post, we’ll explore some of the latest features in ECMAScript 2019 (ES13) and provide code examples to help you get started.

  1. Optional Chaining

Optional Chaining allows you to safely access nested properties without the risk of throwing errors. This is especially useful when dealing with data that may be missing or incomplete.

Here’s an example:

const person = {
  name: 'John',
  address: {
    street: '123 Main St',
    city: 'Anytown',
    state: 'CA',
    zip: '12345'
  }
};

console.log(person?.address?.street); // Output: "123 Main St"
console.log(person?.address?.country); // Output: undefined

In this example, the ?. the operator is used to accessing the street property of the address object. If either person or address is null or undefined, the expression will return undefined instead of throwing an error.

2. Nullish Coalescing

Nullish Coalescing is another feature that allows you to handle null or undefined values more gracefully. It provides a way to provide a default value when a variable is null or undefined, but treats empty strings ('') and 0 as valid values.

Here’s an example:

const name = '';
const defaultName = 'John Doe';
console.log(name ?? defaultName); // Output: ''

In this example, the ?? the operator is used to provide a default value of defaultName when name is an empty string ('').

3. Dynamic Import

Dynamic Import allows you to import modules dynamically at runtime, rather than at compile-time. This can be useful for reducing the size of your initial bundle by only importing modules when they are actually needed.

Here’s an example:

async function loadModule() {
  const module = await import('./myModule.js');
  const myModule = new module.MyModule();
  myModule.doSomething();
}

loadModule();

In this example, the import the function is used to dynamically import the myModule.js module. Once the module has been loaded, we can create an instance of MyModule and call its doSomething method.

  1. Array.prototype.{flat,flatMap}

The flat and flatMap methods are new additions to the Array prototype. The flat the method can be used to flatten nested arrays, while the flatMap the method can be used to map and flatten an array in a single step.

Here’s an example:

const arr = [1, 2, [3, 4, [5, 6]]];
console.log(arr.flat()); // Output: [1, 2, 3, 4, [5, 6]]
console.log(arr.flat(2)); // Output: [1, 2, 3, 4, 5, 6]

const arr2 = ['hello', 'world'];
console.log(arr2.flatMap(x => x.split(''))); // Output: ['h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd']

In the first example, the flat the method is used to flatten the arr array by one

Conclusion

ECMAScript 2019 (ES13) introduces several new features that make it easier to write cleaner and more concise code in JavaScript. Optional Chaining and Nullish Coalescing are particularly useful for handling null and undefined values in a more graceful manner, while Dynamic Import allows you to import modules dynamically at runtime. The addition of flat flatMap methods to the Array prototype also makes it easier to work with nested arrays and map/flatten arrays in a single step. Overall, these new features continue to improve the JavaScript language and make it a more powerful tool for web development.


메타데이터
post_id
1bc8fec3e232
slug
amazing-features-of-es13-1bc8fec3e232
url
https://medium.com/@prabhjot.official01/amazing-features-of-es13-1bc8fec3e232
canonical_url
https://medium.com/@prabhjot.official01/amazing-features-of-es13-1bc8fec3e232
author_url
https://medium.com/@prabhjot.official01
status
ok
fetched_at
2026-07-25 19:35:36