🌈 인프런의
코어 자바스크립트(정재남)
수강 후, 이해한 내용을 정리한 글입니다.
아래 그림에서 빨간 박스 부분을 의미한다.
constructor에 정의된 것은 static, prototype에 직접 정의된 것은 prototype로 분류할 수 있다. 화살표에서 알 수 있듯이 instance에서 static methods, static properties의 접근은 불가능하다. 반면 instance에서 (prototype) methods의 접근은 가능하다.
Array(constructor) 안의 methods와 properties는 각각 static methods
, static properties
이고, prototype 내부의 methods는 (prototype) methods
이다.
// static methods는 instance에서 직접 접근 불가능
❌ [1, 2, 3].isArray()
✅ Array.isArray([1, 2, 3])
// (protytpe) methods는 instance에서 직접 가능
✅ [1, 2, 3].pop()
❌ Array.pop([1, 2, 3])