객체 리터럴
let user = {
    name : 'Mike',
    age : 30,
}

개발을 하다보면 비슷한 객체를 여러개 만들어야 하는 상황이 생긴다.
이 때 사용할 수 있는 것이 생성자 함수이다.

function User(name, age){ // 첫 글자 대문자
    this.name = name;
    this.age = age;
}

let user1 = new User('Mike', 30);
let user2 = new User('Jane', 20);
let user3 = new User('Tom', 17);

와플 판 같은 역할의 생성자 함수로 3개의 객체를 손쉽게 만들었다.

new 함수를 실행하게 되면 빈 객체를 만들고 this 에 할당한다.
function User(name, age){
		//this = {}
		//함수의 본문을 실행하면서 this 의 property 들을 this 에 추가한다.
    this.name = name;
    this.age = age;
		//마지막으로 this를 반환한다.
		//return this;
}
this 와 return this 는 실제 코드에 없다. new 함수를 사용함으로써 실행된다.

매소드를 추가해보자.
function User(name, age){ // 첫 글자 대문자
    this.name = name;
    this.age = age;
		this.sayName = function() {
			console.log(this.name);
		}
}