function extend(...args)
,如果我运行这个函数并传入一个空对象
function extend({})
,如何检查它是否为null或undefined。
输入:const first = { x: 2, y: 3};
const second = { a: 70, x: 4, z: 5 };
const third = { x: 0, y: 9, q: 10 };
const firstSecondThird = extend(first, second, third);
期望输出:{ x: 2, y: 3, a: 70, z: 5, q: 10 }
我还必须检查每个...args
中的条目是否为对象且不为undefined;如果有任何未定义的对象,则必须抛出错误。我还必须检查是否至少有两个参数。