lgwebdream / FE-Interview

🔥🔥🔥 前端面试,独有前端面试题详解,前端面试刷题必备,1000+前端面试真题,Html、Css、JavaScript、Vue、React、Node、TypeScript、Webpack、算法、网络与安全、浏览器
https://lgwebdream.github.io/FE-Interview/
Other
6.87k stars 895 forks source link

Day88:以下两段代码会抛出异常吗?解释原因? #136

Open lgwebdream opened 4 years ago

lgwebdream commented 4 years ago
let yd = { x: 1, y: 2 };
// 以下两段代码会抛出异常吗?
let ydWithXGetter1 = {
  ...yd,
  get x() {
    throw new Error();
  },
};

let ydWithXGetter2 = {
  ...yd,
  ...{
    get x() {
      throw new Error();
    },
  },
};
lgwebdream commented 4 years ago

扫描下方二维码,获取答案以及详细解析,同时可解锁800+道前端面试题。