클래스는 객체지향 프로그래밍의 핵심
class를 통해 생성된 객체를 인스턴스(Class이름에 new 를 붙여서 생성)
메서드는 객체가 프로퍼티 값으로 갖고 있는 것
MyMath
라는 class를 생성해주세요.constructor
에서는 숫자 2개를 인자로 받아 프로퍼티로 저장합니다.getNumber
: 두 개의 숫자가 무엇인지 배열로 반환하는 메서드 → ex) [1, 2]add
: 두 개의 숫자를 더하는 메서드substract
: 두 개의 숫자를 빼는 메서드multiply
: 두 개의 숫자를 곱하는 메서드class MyMath { constructor(a,b){ this.a = a; this.b = b; } getNumber(a,b){ return [this.a , this.b]; } add(a,b){ return this.a + this.b; } substract(a,b){ return this.a - this.b; } multiply(a,b){ return this.a * this.b; } }