function add() { var counter = 0; function plus() { counter += 1; // 상위의 counter 변수 접근 가능 } plus(); return counter; } document.write(add()); // 1출력