다름이아니고 제가 부가세 계산하는 부분을 만들고있습니다
<script>
function ProductConstructor(name, price){
this.name = name,
this.price = price,
this.부가세(){
console.log(this.price * 0.1);
}
}
var shirts = new ProductConstructor('shirts', '50000');
var pants = new ProductConstructor('pants', '60000');
pants.부가세();
</script>
그런데 여기서 에러가 발생합니다
그래서 이렇게 바꿨더니 이건 동작합니다
생성자 펑션 안에서는 함수 선언할때 무조건 두번째 방법을 써야하는건가요?
첫번째 방법으로는 왜 함수선언이 안되는지 궁금합니다