TIL 2021.01.13

louis220·2021년 1월 12일
0

화살표 함수

  • 화살표 함수는 function 키워드를 화살표로 축약해서 표시할 수 있다

    const example = function(x, y) {
    return x + y
    }
    const example = (x, y) => {
    return x + y
    }
  • 화살표 함수의 주의점

    • call, apply, bind 사용 불가능
    • this를 결정하지 않는다

this 키워드

  • this 란 함수 실행시 결정되는 값

    • Global에서는module.exports
    • Function 호출에서는 global
     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 키워드를 사용해서 생성자 호출이 되었을때 이 객체는 인스턴스라고 부른다
인스턴스.메소드() 의 형태의 호출

profile
기록을 하자

0개의 댓글