[15m] Object literals & Constructors
# Object literals & Constructors
- Object literals (객체 리터럴): Objects created using object literals are singletons. This means when a change is made to the object, it affects that object across the entire script.
- Constructors (생성자): Object defined with a function constructor lets you have multiple instances of that object. This means change made to one instance will not affect other instances.
# Notes
- 나는 1번처럼 만들어야만 하는 줄 알았는데, 여기서는 2번처럼 만들었다. 방법이 여럿이구나.
// 1번: function으로 시작함
function emp () {
this.name = "John";
}
// 2번: 'emp는 function이다' 하는 식으로 풀어냄
var emp = function () {
this.name = "John";
}
# 다음에 할 일
- objects, instances: 차이를 알아보기 (instances가 더 구체적이고 실질적인 대상 같은 느낌이긴 한데...)
- Object literals, Object.create(), Constructors: 이제 Object.create()를 알아보기
- async-await 따라해보기. (하다 말았음): https://milimiliemilie.tistory.com/11 여기의 JS Crash course 참고.