//์์ฑ์ ํจ์ : ์ํ ๊ฐ์ฒด๋ฅผ ์์ฑํด๋ณด์
function Item(title, price){
//this={}
this.title = title;
this.price = price;
this.showPrice = function(){
console.log(`๊ฐ๊ฒฉ์ ${price}์ ์
๋๋ค.`);
};
//return this;
}
const item1 = new Item('์ธํ', 3000);
const item2 = new Item('์ง๊ฐ', 6000);
const item3 = new Item('๊ฐ๋ฐฉ', 9000);
console.log(item1,item2,item3);
item3.showPrice();
const item1 = new Item('์ธํ', 3000);
const item2 = Item('์ง๊ฐ', 6000);
const item3 = new Item('๊ฐ๋ฐฉ', 9000);
new๋ฅผ ์๋ตํ item2๋ ๊ฐ์ ๋ฐํํ์ง ๋ชปํจ
'js' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
javascript ๋ฐฐ์ด ๋ฉ์๋2(sort, reduce) (1) | 2022.10.04 |
---|---|
javascript ๋ฐฐ์ด ๋ฉ์๋(Array methods) (0) | 2022.10.04 |
javascript ์ซ์ ์ํ method (0) | 2022.09.01 |
javascript ์ฌ๋ณผ(Symbol) (0) | 2022.08.31 |
javascript ๊ฐ์ฒด ๋ฉ์๋(Object methods), ๊ณ์ฐ๋ ํ๋กํผํฐ(Computed propery) (0) | 2022.08.29 |