// AS-IS
var oldFunc = function() {
console.log('Old Function');
}
var oldEs = 'ES';
var oldObj = {
sayJs : function() {
console.log('JS');
},
oldFunc: oldFunc
};
oldObj[oldEs+6] = 'Wow';
oldObj.oldFunc(); // Old Function
oldObj.sayJs(); // JS
console.log(oldObj.ES6); // Wow
// TO-DO
const newFunc = function() {
console.log('New Function');
}
const newEs = 'ES';
const newObj = {
sayJs() { // sayJs 객체의 메서드에 함수 연결 시 콜론과 function를 붙이지 않음
console.log('JS');
},
newFunc, // newFunc: newFunc 처럼 속명명과 변수명이 동일하면 한 번만 써도 됨
[newEs+6]: 'Wow' // 객체의 속성명을 동적으로 생성
};
newObj.newFunc(); // New Function
newObj.sayJs(); // JS
console.log(newObj.ES6); // Wow
Ly8gQVMtSVMKdmFyIG9sZEZ1bmMgPSBmdW5jdGlvbigpIHsKCWNvbnNvbGUubG9nKCdPbGQgRnVuY3Rpb24nKTsKfQp2YXIgb2xkRXMgPSAnRVMnOwp2YXIgb2xkT2JqID0gewoJc2F5SnMgOiBmdW5jdGlvbigpIHsKCQljb25zb2xlLmxvZygnSlMnKTsKCX0sCglvbGRGdW5jOiBvbGRGdW5jCn07Cm9sZE9ialtvbGRFcys2XSA9ICdXb3cnOwpvbGRPYmoub2xkRnVuYygpOwkvLyBPbGQgRnVuY3Rpb24Kb2xkT2JqLnNheUpzKCk7CQkvLyBKUwpjb25zb2xlLmxvZyhvbGRPYmouRVM2KTsJLy8gV293CgovLyBUTy1ETwpjb25zdCBuZXdGdW5jID0gZnVuY3Rpb24oKSB7Cgljb25zb2xlLmxvZygnTmV3IEZ1bmN0aW9uJyk7Cn0KY29uc3QgbmV3RXMgPSAnRVMnOwpjb25zdCBuZXdPYmogPSB7CglzYXlKcygpIHsJCQkvLyBzYXlKcyDqsJ3ssrTsnZgg66mU7ISc65Oc7JeQIO2VqOyImCDsl7DqsrAg7IucIOy9nOuhoOqzvCBmdW5jdGlvbuulvCDrtpnsnbTsp4Ag7JWK7J2MCgkJY29uc29sZ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