Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

JS 2017

JavaScript Version Numbers

Earlier ECMAScript versions were named by numbers, such as ES5 and ES6. Starting in 2016, versions are referred to by the year of release, like ES2016, ES2018, ES2020, and so on.

New Features in ECMAScript 2017

This chapter covers the new features introduced in ECMAScript 2017:

  • JavaScript String Padding
  • JavaScript Object.entries() method
  • JavaScript Object.values() method
  • JavaScript async and await
  • Trailing Commas in Functions
  • JavaScript Object.getOwnPropertyDescriptors

ES2017 has been fully supported in all modern browsers since September 2017.

js 9

JavaScript String Padding

ECMAScript 2017 introduced two string methods to JavaScript: padStart() and padEnd(), which allow padding at the beginning and end of a string, respectively.

Examples

let text = “5”;
text = text.padStart(4,0);
let text = “5”;
text = text.padEnd(4,0);

JavaScript string padding has been supported in all modern browsers since April 2017.

js 10

JavaScript Object Entries

ECMAScript 2017 introduced the Object.entries() method, which returns an array of key/value pairs from an object.

Example

const person = {
  firstName : “John”,
  lastName : “Doe”,
  age : 50,
  eyeColor : “blue”
};

let text = Object.entries(person);

The Object.entries() method makes it easy to iterate over objects in loops.

Example

const fruits = {Bananas:300, Oranges:200, Apples:500};

let text = “”;
for (let [fruit, value] of Object.entries(fruits)) {
  text += fruit + “: “ + value + “<br>”;
}

The Object.entries() method also simplifies converting objects into maps.

Example

const fruits = {Bananas:300, Oranges:200, Apples:500};

const myMap = new Map(Object.entries(fruits));

The Object.entries() method has been supported in all modern browsers since March 2017.

js 11