ES6 perguntas e respostas de entrevista
Pergunta 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);
Pergunta 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);
Pergunta 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);
Pergunta 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);
Pergunta 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); }
Mais uteis segundo os usuarios: