JavaScript ES7

JavaScript Tutorial

JavaScript ES7+ Features (ES2016+)

After ES6, JavaScript ES7 introduced several new features every year. ES7 and above focus on making code simpler, cleaner, and more powerful.


1️⃣ Exponentiation Operator (**) – ES7

  • Replaces Math.pow() for calculating powers.


Equivalent:



2️⃣ Array.prototype.includes() – ES7

  • Checks if an array contains a value (returns true/false).


Works for strings too:



3️⃣ Object.values() and Object.entries() – ES8

  • Object.values(obj) – Returns array of values

  • Object.entries(obj) – Returns array of [key, value] pairs


 


4️⃣ String Padding – ES8

  • padStart() – Adds characters at the start

  • padEnd() – Adds characters at the end



5️⃣ Trailing Commas in Functions / Arrays / Objects – ES8


 


6️⃣ Async/Await – ES8

  • Already covered in detail.

  • Makes Promise-based code easier to read.



7️⃣ Object Spread / Rest Properties – ES9 (2018)

  • Spread (...) – Copy or merge objects

  • Rest (...) – Extract remaining properties


 


8️⃣ Optional Chaining (?.) – ES11 (2020)

  • Access nested object properties safely without errors.



9️⃣ Nullish Coalescing (??) – ES11 (2020)

  • Returns the right-hand value only if left-hand is null or undefined.


 


10️⃣ BigInt – ES2020

  • Store very large integers beyond Number.MAX_SAFE_INTEGER.



11️⃣ Dynamic Imports – ES2020

  • Load modules on-demand using import().



12️⃣ Logical Assignment Operators – ES2021


 


Summary Table

Feature Introduced Example
Exponentiation ES7 2 ** 3
Array.includes() ES7 [1,2].includes(2)
Object.values() / entries() ES8 Object.values(obj)
String padding ES8 "5".padStart(3, "0")
Async/Await ES8 await fetch()
Object spread/rest ES9 { ...obj }
Optional chaining ES11 user?.address?.city
Nullish coalescing ES11 x ?? 10
BigInt ES2020 123n
Dynamic import ES2020 import("./module.js")
Logical assignment ES2021 `a

You may also like...