# 만약 Samgsung Store에서 판매자로 일하고 있고,
tv의 종류를 이름,가격,크기에 맞게 등록을 해야된다면?
수량이 많아질수록 너무 번거로운 작업들이 많아짐
let name="Sangsung Store"
let tv1 = {
name: 'Santino TV',
price: 200,
size: '26inch'
}
let tv2 = {
name: 'Martin TV',
price: 200,
size: '26inch'
}
let tv3 = {
name: 'Hyun TV',
price: 200,
size: '26inch'
}
console.log(tv1);
----------------------------
출력값 :
PS C:\Users\User\desktop\samsungTV> node main1.js
{ name: 'Santino TV', price: 200, size: '26inch' }
* tv1,tv2,tv3에서 중복되어 사용되는 값들(name,price,size)를 새로운 class에
묶어서 사용 가능함
+ constructure 사용해야 함
# constructure = 클래스에 있는 속성들의 값을 넣어주는 (초기화 시켜주는) 함수
class TV {
name="";
price=0;
size=""
constructor(name,price,size){ //constructure 생성자
this.name=name
this.price=price
this.size=size
}
}
// 여기서 new + 클래스 이름을 작성해주기
let tv1 = new TV('Santino TV', 200, '26inch')
// let tv1 = {
// name: 'Santino TV',
// price: 200,
// size: '26inch'
// }