Sitemap
Shaan Gola

Shaan Gola

Frontend Architect @ LTIMindtree , MERN Stack

Exploring the Latest Features in ECMAScript 2017 (ES8) JavaScript

2 min readJan 20, 2024

ECMAScript, the standard upon which JavaScript is based, undergoes regular updates to enhance the language and provide developers with powerful tools and features. One significant update is ECMAScript 2017, also known as ES8, which introduced several new features and improvements. In this article, we’ll explore the latest additions to JavaScript, highlighting how they enhance the language and make developers’ lives easier.

Get Shaan Gola’s stories in your inbox

Join Medium for free to get updates from this writer.

1. Object.values() and Object.entries():
— Object.values():
— Returns an array containing the values of an object’s enumerable property values.
— Simplifies extracting values without needing to iterate over keys.

const myObject = { a: 1, b: 2, c: 3 };
const valuesArray = Object.values(myObject);
// Output: [1, 2, 3]

- Object.entries():
— Returns an array containing arrays of key-value pairs for each enumerable property.
— Useful for iterating over objects and working with both keys and values.

const myObject = { a: 1, b: 2, c: 3 };
const entriesArray = Object.entries(myObject);
// Output: [['a', 1], ['b', 2], ['c', 3]]

2. String padding:
— Two new methods, `String.padStart()` and `String.padEnd()`, enable developers to pad strings with spaces or other characters to meet a specified length.

const paddedString = '5'.padStart(3, '0');
// Output: '005'

3. Async Functions (Async/Await):
— While introduced in ES2015 (ES6), ES2017 further enhances asynchronous programming with async functions and the `await` keyword.
— Provides a cleaner syntax for handling asynchronous operations, making code more readable.

async function fetchData() {
try {
const response = await fetch('https://api.example.com/data');
const data = await response.json();
// Handle data
} catch (error) {
// Handle errors
}
}

4. Shared Memory and Atomics (SharedArrayBuffer and Atomics):
— Introduces `SharedArrayBuffer`, enabling the creation of shared memory regions among web workers.
— The `Atomics` object provides atomic operations on shared memory locations, preventing race conditions.

const buffer = new SharedArrayBuffer(16);
const view = new Int32Array(buffer);
Atomics.add(view, 0, 1);

5. Trailing Commas in Function Parameter Lists:
— Allows developers to add trailing commas in function parameter lists without causing syntax errors.

function myFunction(param1, param2,) {
// Function body
}

Conclusion:

ECMAScript 2017 brings several valuable additions to JavaScript, emphasizing simplicity, readability, and improved functionality. Features like `Object.values()` and `Object.entries()` streamline object manipulation, while async functions and shared memory support advance asynchronous programming and concurrency. By staying abreast of these updates, developers can leverage the latest language features to write more concise, expressive, and efficient JavaScript code. As the JavaScript ecosystem evolves, embracing these enhancements ensures that developers can continue building robust and modern applications.

Keep exploring and coding! 🚀

--

--

Shaan Gola
Shaan Gola

Written by Shaan Gola

Frontend Architect @ LTIMindtree , MERN Stack