전역객체 window
Window 객체
모든 객체가 소속된 객체로서 전역객체'이면서 창이나 프레임을 의미

<script>
alert('hello world');
window.alert('hello world');
</script>
alert('hello world');의 앞에 window가 생략되어 있는 것
alert = window의 메소드
예시) 전역변수 a에 접근하는 방법
<script>
let a = 1;
alert(a);
alert(window.a);
</script>
<script>
let b = {id:1};
alert(b.id);
alert(window.b.id);
</script>
전역변수와 함수 = window 객체의 프로퍼티와 메소드
객체를 만든다는 것은 결국 window 객체의 프로퍼티를 만드는 것과 같음을 의미
모든 객체는 window라는 객체에 소속되어있는 자식
Last updated
Was this helpful?