생성자 함수를 이용하여 객체를 생성할 수 있다.

질문 : 스코프 세이프 생성자 247페이지 란 정확히 문지

this instanceof Circle문법은 어떤것인지.

Object 생성자 함수

new Object(); // {} 

위 코드는 빈 객체를 반환한다

이후 프로퍼티나 메서드를 추가하여 객체를 완성할 수 있다.

생성자함수: new 연산자와 함께 호출하여 객체(인스턴스)를 생성하는 함수

Object외에도 String,Number,Bollean,Function,Array,Date,RegExp,Promise등의 빌트인 생성자 함수를 지원한다.

생성자 함수

객체 리터럴은 단 하나의 객체만 생성할 수 있지만

프로퍼티 구조가 동일한 여러 객체를 만들때는 생성자 함수가 효율적이다.

function Circle(radius){ //첫대문자가 관례
		this.radius = radius;
		this.getDiameter = function() {
				return 2 * this.radius;				
			};
	}

const circle1 = new Circle(5);
const circle2 = new Circle(10);
//생성자 함수를 통해 유사한 두 객체를 만들어낸 모습
{
radius : 5 ,
getiameter() {
this.radud
dsfadfasf
}

}