解构赋值与展开运算符 — 计算机选择题
题目
已知:
const a = {x: 1, y: 2};
const b = {y: 5, z: 7};
const c = {...a, ...b, x: 8};
const {x: p, y, ...rest} = c;
以下哪项准确表示变量 p、y 和 rest 的值?
A. p 为 1,y 为 5,rest 为 {z: 7}
B. p 为 8,y 为 2,rest 为 {z: 7}
C. p 为 8,y 为 5,rest 为 {z: 7}
D. p 为 8,y 为 5,rest 为 {x: 8, z: 7}