ES6 (ECMAScript 2015) introduced several new methods for working with arrays, strings, objects, and more. These methods enhance the functionality of JavaScript, making it more efficient and readable. Here’s a summary of some key ES6 methods:
1. Array Methods
Array.from(): Creates a new array from an array-like or iterable object.
javascript
Copy code
const str = 'hello';
const arr = Array.from(str); // ['h', 'e', 'l', 'l', 'o']
Array.of(): Creates a new array with the given arguments.
javascript
Copy code
const arr = Array.of(1, 2, 3); // [1, 2, 3]
Array.prototype.find(): Returns the first element in an array that satisfies the provided testing function.
javascript
Copy code
const arr = [5, 12, 8, 130, 44];
const found = arr.find(element => element > 10); // 12