화살표 함수는 function 키워드를 화살표로 축약해서 표시할 수 있다
const example = function(x, y) {
return x + y
}
const example = (x, y) => {
return x + y
}
화살표 함수의 주의점
this 란 함수 실행시 결정되는 값
class math{
constructor() {
this.value = 0;
}
increase(){
this.value++
}
decrease() {
this.value--
}
getValue(){
return this.value
}
let example = new math()
example.increas()
example.decrease()
example.getValue() // 0
new 키워드를 사용해서 생성자 호출이 되었을때 이 객체는 인스턴스라고 부른다
인스턴스.메소드() 의 형태의 호출