JavaScript 2017
JavaScript Basics

JavaScript 2017

Overview of ECMAScript 2017

ECMAScript, commonly referred to by its version numbers such as ES5 and ES6, began naming versions by year starting in 2016. The ECMAScript 2017 release, also known as ES8, introduced several new features that enhance JavaScript's capabilities.

New Features in ECMAScript 2017

  • JavaScript String Padding: Adds methods to pad strings at the beginning or end.
  • JavaScript Object Entries and Values: Provides methods to work with object properties.
  • JavaScript Async Functions and Await: Simplifies writing asynchronous code.
  • Trailing Commas in Functions: Allows trailing commas in function parameter lists.
  • JavaScript Object.getOwnPropertyDescriptors: Returns all own property descriptors of an object.

Browser Support for ECMAScript 2017

By September 2017, ECMAScript 2017 was fully supported by all major browsers:

  • Chrome 57 (March 2017)
  • Edge 15 (April 2017)
  • Firefox 48 (August 2016)
  • Safari 11 (September 2017)
  • Opera 44 (March 2017)

Detailed Feature Examples and Browser Support

1. JavaScript String Padding

let text = "5";
text = text.padStart(4, '0');  // Outputs '0005'
text = text.padEnd(4, '0');    // Outputs '5000'

Supported since April 2017 in:

  • Chrome 57, Edge 15, Firefox 48, Safari 10, Opera 44

2. JavaScript Object Entries

const person = {
  firstName: "John",
  lastName: "Doe",
  age: 50,
  eyeColor: "blue"
};
let entries = Object.entries(person);
// Use entries in loops or convert to maps

Supported since March 2017 in:

  • Chrome 47, Edge 14, Firefox 47, Safari 10.1, Opera 41

3. JavaScript Object Values

const person = {
  firstName: "John",
  lastName: "Doe",
  age: 50,
  eyeColor: "blue"
};
let values = Object.values(person); // ['John', 'Doe', 50, 'blue']

Supported since March 2017 in:

  • Chrome 54, Edge 14, Firefox 47, Safari 10.1, Opera 41

4. JavaScript Async Functions

async function myDisplay() {
  let myPromise = new Promise((resolve, reject) => {
    setTimeout(() => { resolve("I love You !!"); }, 3000);
  });
  document.getElementById("demo").innerHTML = await myPromise;
}
myDisplay();

Supported since September 2017 in:

  • Chrome 55, Edge 15, Firefox 52, Safari 11, Opera 42

5. JavaScript Trailing Commas

function myFunc(x,,,) {};
const myArr = [1, 2, 3, 4,,,];
const myObj = {fname: "John", age: 50,,,};

Supported since May 2017 in:

  • Chrome 58, Edge 14, Firefox 52, Safari 10, and Opera 45

Take a look into your desired course