본문 바로가기
TIL

클로저

by 은지:) 2023. 5. 19.
728x90
반응형

 

 

 

 

 

 

const order = (food) => {
  return (drink) => console.log(`음식 : ${food}, 음료 : ${drink}`)
}


let a = order("밥")

a("콜라")
a("사이다")

 

 

class Car {
  constructor(name,price){
    this.name = name
    this.price = price
    this.place = "판교현백"
  }

  applyDiscount(discount) {return this.price*discount}
  
  
  changePlace(placeName) {return this.place = placeName}
}


const instance = new Car("EUNJI",2000)


const ab = () => {
  instance.changePlace("판교")
  console.log(instance)  
}
ab()

 

 

 

 

 

++ 추가 예정

 

 

 

 

 

728x90
반응형

'TIL' 카테고리의 다른 글

react) typescript 에서 svg 파일 어떻게 쓰나요  (0) 2023.05.30
컨테이너화  (0) 2023.05.21
Web Server와 WAS  (1) 2023.05.18
docker 이미지 / 컨테이너 만들기  (0) 2023.05.18
낙관적 업데이트 & finally()  (0) 2023.05.15

댓글