
[JS] JS 클래스 (new, this, prototype)
2022. 2. 15. 07:29
개발이야기/JS
const seo0 = { firstName: 'seo0', lastName: 'yoon', getFullName: function () { return `${this.firstName} ${this.lastName}` } } console.log(seo0) 객체데이터가 있고, firstname, lastname은 속성(프로퍼티), 프로퍼티에 함수가 할당되어있으면 '메소드'라고 부르기로 약속했다. `${}` 백틱기호를 활용하여 데이터를 보관하려고 한다. 여기서, this라는 부분은 바로 우리가 위에서 지정했던 seo0으로 생각하면 된다. this = seo0 하지만 seo0은 변수에 할당했기때문에 언제든지 바뀔수있는 구조이고 이부분을 염두해둬야하기때문에 this라는것을 통해서 지칭한다. (this에 대한..