ES6 면접 질문과 답변
Ques 11. What is the purpose of the 'map' function in ES6?
The 'map' function is used to transform each element of an array and create a new array with the results.
Example:
const numbers = [1, 2, 3]; const doubled = numbers.map(num => num * 2);
도움이 되었나요?
Add Comment
View Comments
Ques 12. Explain the 'filter' function in ES6.
The 'filter' function is used to create a new array with elements that satisfy a given condition.
Example:
const numbers = [1, 2, 3, 4, 5]; const evens = numbers.filter(num => num % 2 === 0);
도움이 되었나요?
Add Comment
View Comments
Ques 13. What is the purpose of the 'reduce' function in ES6?
The 'reduce' function is used to accumulate the elements of an array into a single value.
Example:
const numbers = [1, 2, 3, 4, 5]; const sum = numbers.reduce((acc, num) => acc + num, 0);
도움이 되었나요?
Add Comment
View Comments
Ques 14. Explain the 'find' function in ES6.
The 'find' function is used to find the first element in an array that satisfies a given condition.
Example:
const numbers = [1, 2, 3, 4, 5]; const result = numbers.find(num => num > 2);
도움이 되었나요?
Add Comment
View Comments
Ques 15. What are the rest parameters in ES6?
Rest parameters allow a function to accept an indefinite number of arguments as an array.
Example:
function sum(...numbers) { return numbers.reduce((acc, num) => acc + num, 0); }
도움이 되었나요?
Add Comment
View Comments
Most helpful rated by users: