Guest User

Untitled

a guest
Jun 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. // 어디선가 site property 가 바뀌고 있다.
  2. var ooo = obj.site; // 백업
  3. Object.defineProperty(obj, 'site', {
  4. set: function (newValue) {
  5. try { throw new Error('set!'); } catch (err) { console.error(err); }
  6. this.ooo = newValue; // ooo 말고 안 쓰는 property 이름을 쓴다
  7. },
  8. get: function () { try { throw new Error('get!'); } catch (err) { console.error(err); } return this.ooo; }
  9. });
  10. obj.site = ooo; // 값 복구 및 동작확인
  11. // Error 객체를 throw 하지 않고 그냥 에러 객체에서 stack을 찍어봐도 된다.
  12. // 그치만 나는 빨간색이 좋다
Add Comment
Please, Sign In to add comment