ES6 面接の質問と回答
質問 21. What is the 'default parameter value' feature in ES6?
Default parameter values allow you to specify default values for function parameters if no value or undefined is passed.
Example:
function greet(name = 'Guest') { console.log(`Hello, ${name}!`); }
役に立ちましたか?
コメントを追加
コメントを見る
質問 22. Explain the 'Object.assign()' method in ES6.
Object.assign() is used to copy the values of all enumerable own properties from one or more source objects to a target object.
Example:
const target = {}; const source = { a: 1, b: 2 }; Object.assign(target, source);
役に立ちましたか?
コメントを追加
コメントを見る
質問 23. What is the 'Array.from()' method in ES6?
Array.from() is used to create a new shallow-copied array from an array-like or iterable object.
Example:
const arrayLike = { 0: 'a', 1: 'b', length: 2 }; const newArray = Array.from(arrayLike);
役に立ちましたか?
コメントを追加
コメントを見る
質問 24. Explain the 'Array.of()' method in ES6.
Array.of() is used to create a new array with a variable number of arguments, regardless of their types.
Example:
const newArray = Array.of(1, 'hello', true);
役に立ちましたか?
コメントを追加
コメントを見る
質問 25. What is the purpose of the 'Array.findIndex()' method in ES6?
Array.findIndex() is used to find the index of the first element in an array that satisfies a given condition.
Example:
const numbers = [1, 2, 3, 4, 5]; const index = numbers.findIndex(num => num > 2);
役に立ちましたか?
コメントを追加
コメントを見る
ユーザー評価で最も役立つ内容: