211101 TIL JS-ES6 (학습 96일차)

김영진·2021년 11월 1일
0

ES6 기초 학습

  • 화살표 함수는 실행문이 1개일 경우 아래와 같이 {}, return 생략 가능
  const numB = data.filter((vlaue, index) => typeof value === 'number');
  • 객체지향 Class
   // 기존에 사용했던 객체 생성과 상속 구문을 체계적인 객체지향 구문으로 보완
    class Info {
      constructor(a,b) {
        this.subject = a;
        this.credit = b;
        this.days = [80, 120,  140];
        this.day = this.days[0];
      }

      printOut() {
        return this.subject + ',' + this.credit + '학점';
      }
      get lessontime() {
        return this.day;
      }
      set lessontime(num) {
        this.day = this.days[num];
      }
    }

    let sub1 = new Info('html', 1);
    console.log(sub1.printOut());
    console.log(sub1.lessontime);
    sub1.lessontime = 1;
    console.log(sub1.lessontime);
profile
UI개발자 in Hivelab

0개의 댓글