Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Java Script/2011년스터디/서지혜

From ZeroWiki
Revision as of 06:50, 18 January 2011 by imported>rabierre
== 함수 ==
    • 중첩함수
  • 중첩 함수 예
function duple_test() {
  function inner() {
    /* body comes here */
  }
}	// good
  • 내부 익명함수는 접근할 수 없기 때문에 안됨
function duple_test() {
	function () {
          /* body comes here */
	} // anonymous inner class can't be reached
}	// bad
  • 이 방법은 된다
function duple_test() {
	var one = function () {
	} // anonymous but reachable
}	
  • 여러번 중첩되어도 된다
function one(){
	function two() {
		function three() {
                      /* body comes here */
		}
	}
}	// good
    • 함수 파라메터
/* Arguments 객체 테스트 */
function arg_test(one, two) {
	document.write(one);
	document.write(arguments[0]);
	
	document.write(two);
	document.write(arguments[1]);

	document.write(arguments.length);

	document.write(arguments[3]);	// 존재하지 않는 배열을 참조한다면? -> undefined

	arguments[3] = 5;				// 내부에서 파라메터 삽입 가능!!
	document.write(arguments[3]);
}

arg_test(3, 4);