for/of Loop
The for…of loop in JavaScript iterates over iterable objects, like arrays, strings, for concise and readable element access and iteration.
Syntax:
for ( variable of iterableObjectName) {
. . .
}
Example: In this example, the for…of loop iterates over each element in the numbers array and logs each number to the console.
Javascript
const numbers = [1, 2, 3, 4, 5]; for (const num of numbers) { console.log(num); }; |
Output
1 2 3 4 5
JS 2015 or ECMAScript 6 (ES6)
JS 2015 (ES6) also known as ECMAScript 6 (ES6), ECMAScript 6 (ES6) is a significant update to JavaScript, introducing arrow functions, classes, template literals, let and const for variable declaration, enhanced object literals, destructuring, and more modern features for better code organization and readability.
Contact Us