1. 일반함수실행방식(regular function call)

ex) function ex1(){ console.log(this); // this : window객체 }

ex1();

// this로 전역변수를 호출할 경우

var name = 'chris'; // 전역변수

function ex1(){ console.log(this.name); // 전역객체(this)를 통해 전역변수(name)에 접근 }

ex1(); // this.name == window.name >> 'chris'

* strict mode(엄격모드. 스크립트 최상단에 'use strict'; 추가)에서의 일반함수실행방식

ex) 'use strict'; // 엄격모드 사용

var name = 'chris'; // 전역변수

function ex2() { console.log(this.name); // this == undifined (속성이 없음) }

ex2(); // error 출력

2. 도트 표기법(dot notation)

ex) var age = 100; // 전역변수