본문 바로가기

JavaScript

자바스크립트 문법 (8)

전역 객체(global object)

 

자바스크립트에 미리 정의된 객체로 전역 프로퍼티나 전역 함수를 담는 공간의 역할

전역범위에서 this 연산자를 통해 접근할 수 있음

 

래퍼 객체(wrapper object)

 

숫자, 문자열, 불리언 등 원시 타입의 프로퍼티에 접근하려고 할 때 생성되는 임시 객체를

래퍼 객체라고 함.

 

var str = "문자열";
var strObj = new String(str);

document.write(str.length + "<br>");
document.write((str == strObj) + "<br>" );
document.write((str === strObj) + "<br>" );
document.write(typeof str + "<br>");
document.write(typeof strObj);

 

//3
true
false
string
object