ES6 Pertanyaan dan Jawaban Wawancara
Ques 26. Explain the 'Array.includes()' method in ES6.
Array.includes() is used to check if an array includes a certain element, returning true or false.
Example:
const numbers = [1, 2, 3, 4, 5]; const includesThree = numbers.includes(3);
Ques 27. What is the 'Object.entries()' method in ES6?
Object.entries() is used to return an array of a given object's own enumerable string-keyed property [key, value] pairs.
Example:
const obj = { a: 1, b: 2 }; const entries = Object.entries(obj);
Ques 28. Explain the 'Object.keys()' method in ES6.
Object.keys() is used to return an array of a given object's own enumerable string-keyed property names.
Example:
const obj = { a: 1, b: 2 }; const keys = Object.keys(obj);
Ques 29. What is the purpose of the 'Object.values()' method in ES6?
Object.values() is used to return an array of a given object's own enumerable string-keyed property values.
Example:
const obj = { a: 1, b: 2 }; const values = Object.values(obj);
Ques 30. Explain the concept of the 'for...of' loop in ES6.
The 'for...of' loop is used to iterate over values in an iterable object, such as an array, string, or Map.
Example:
const arr = [1, 2, 3]; for (const num of arr) { console.log(num); }
Most helpful rated by users: