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