๋ฐ์ํ
const calculator = {
add: function(a,b){
console.log(a+b);
}
minus: function(a,b){
console.log(a-b);
}
}
calculator.add(1,2);
calculator.minus(1,2);
SyntaxError: Unexpected identifier 'minus'. Expected '}' to end an object literal.
์ด๋ฐ ์ค๋ฅ๊ฐ ๋ฌ๋ค.
}๊ฐ ํ์ํ๋ค๊ณ ํ๋๋ฐ ๋๋ ์ด์์์ด ๋ค ๋ซ์๋ค...
const calculator = {
add: function(a,b){
console.log(a+b);
},
minus: function(a,b){
console.log(a-b);
},
mul: function(a,b){
console.log(a*b);
},
div: function(a,b){
console.log(a/b);
},
power: function(a,b){
console.log(a**b);
},
}
calculator.add(1,2);
calculator.minus(1,2);
calculator.mul(1,2);
calculator.div(1,2);
calculator.power(1,2);
[Log] 3 (app.js, line 3)
[Log] -1 (app.js, line 6)
[Log] 2 (app.js, line 9)
[Log] 0.5 (app.js, line 12)
[Log] 1 (app.js, line 15)
์ผํ๋ฅผ ์ผ๋๋ ์ถ๋ ฅ์ด ๋๋ค...
๋ฐ์ํ