let count = 1 const preIncrement = ++count // 2
let count = 1 const postIncrement = ++count // 1
class Notebook { constructor(name, price, company) { this.name = name this.price = price this.company = company } // 메서드 선언 printInfo() { console.log(`상품명: ${this.name}, 가격: ${this.price}원`) } }
const notebook1 = new Notebook('MacBook', 2000000, 'Apple') notebook1.printInfo() // 상품명: MacBook, 가격: 2000000원
const computer = { name: 'Apple Macbook', price: 20000, printInfo: function () { console.log(`상품명: ${this.name}, 가격: ${this.price}원`) } } computer.printInfo()
const rainbowColors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'] for (const color of rainbowColors) { console.log(color) }