The seventh release of the ECMAScript language specification (ES2016). Because ES6 has been updated so much at once, two small features have been added to ES7.

Array.prototype.includes

Used to determine whether an array contains a specified value, returning true if it does, false otherwise.

console.log(['a'.'b'.'c'].includes('a'));  // true
console.log(['a'.'b'.'c'].includes('d'));  // false
Copy the code

Before this, we usually use array.prototype.indexof.

console.log(['a'.'b'.'c'].includes('a'));        // true
console.log(['a'.'b'.'c'].indexOf('a')! = = -1);  // true
Copy the code

The only difference is that includes() finds NaN, while indexOf() does not.

console.log([NaN].includes(NaN));  // true
console.log([NaN].indexOf(NaN));   // -1
Copy the code

Exponentiation Operator Exponentiation Operator

Simplify math.pow (a, b) with a ** B.

console.log(2 ** 3);          / / 2 * 2 * 2 = 8
console.log(Math.pow(2.3));  / / 2 * 2 * 2 = 8
Copy the code

collection

  • New features of ES2022(ES13
  • New features of ES2021(ES12
  • New features for ES2020(ES11)
  • Nine new features that ES2019(ES10) brings
  • ES2018 (ES9) new features
  • ES2017 (ES8) new features
  • ES2016 (ES7) new features