Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 백준알고리즘
- display : none
- filter()
- 등차수열의 항 찾기
- nth-child()
- 배열과 연결리스트의 차이
- for..of
- 단방향 연결리스트
- visibility : hidden
- 배열의 내림차순
- 배열의 오름차순
- Sort
- 가상 요소 선택자
- indexOf
- innerhtml
- classList.contains(string)
- 쌍방향 연결리스트
- 범용 선택자
- CSS
- 인접 형제 선택자 결합
- Em
- Link
- map()
- disabled
- 양방향 연결리스트
- 일반 형제 선택자 결합
- 객체
- invalid assignment left-hand side
- 고차함수
- Array.from()
Archives
- Today
- Total
프론트엔드 센트럴파크 (☞゚ヮ゚)☞
프로토타입 본문
- 어떠한 객체가 만들어지기 위해 객체의 모태가 되는 원형
- 자바스크립트는 일반적인 객체지향 언어와는 다르게, 프로토타입을 이용한 복사를 통해 새로운 객체 생성
- 일반적인 객체 생성 방식 : 속성은 생성자, 메서드는 프로토타입에서 정의
// 생성자 속성 정의
function Person(name, age) {
this.name = name;
this.age = age;
};
// prototype을 이용한 Person 메서드 정의
Person.prototype.isAdult = function() {
return this.age > 18;
};
// 객체 생성
const p1 = new Person("kitty", 22);
const p2 = new Person("james", 18);
console.log(p1);
console.log(p2);
console.log(p1.isAdult());
console.log(p2.isAdult());
'Javascript' 카테고리의 다른 글
commonJS로 JS파일 연동하기 (0) | 2022.07.27 |
---|---|
classList.contains(string) (0) | 2022.07.23 |
거듭제곱 / 제곱근 (0) | 2022.07.20 |
배열 숫자의 오름차순, 내림차순 정렬 (0) | 2022.07.20 |
배열 내 모든 요소가 콜백 함수의 조건을 만족하면 true/false - every() (0) | 2022.07.20 |
Comments