fork download
  1. // AS-IS
  2. let beforeObj = {
  3. status: {
  4. bfName: 'node',
  5. bfCount: 5
  6. },
  7. getBeforeObj: function () {
  8. this.status.bfCount--;
  9. return this.status.bfCount;
  10. }
  11. };
  12.  
  13. let getBeforeObj = beforeObj.getBeforeObj;
  14. let bfCount = beforeObj.status.bfCount;
  15.  
  16.  
  17. // TO-BE : 객체의 속성을 같은 이름의 변수에 대입
  18. let afterObj = {
  19. status: {
  20. afName: 'node',
  21. afCount: 5
  22. },
  23. getAfterObj() {
  24. this.status.afCount--;
  25. return this.status.afCount;
  26. }
  27. };
  28.  
  29. let { getAfterObj, status: { afCount } } = afterObj;
  30.  
  31.  
  32. console.log('getBeforeObj', getBeforeObj);
  33. console.log('bfCount', bfCount);
  34.  
  35. console.log('getAfterObj', getAfterObj);
  36. console.log('afCount', afCount);
  37.  
Success #stdin #stdout 0.02s 16708KB
stdin
Standard input is empty
stdout
getBeforeObj function () {
		this.status.bfCount--;
		return this.status.bfCount;
	}
bfCount 5
getAfterObj getAfterObj() {
		this.status.afCount--;
		return this.status.afCount;
	}
afCount 5