More actions
imported>rabierre No edit summary |
imported>rabierre No edit summary |
||
| Line 38: | Line 38: | ||
document.write(arguments.length); | document.write(arguments.length); | ||
document.write(arguments[3]); // 존재하지 않는 배열을 참조한다면? | document.write(arguments[3]); // 존재하지 않는 배열을 참조한다면? -> undefined | ||
arguments[3] = 5; // 파라메터 삽입 가능 | arguments[3] = 5; // 내부에서 파라메터 삽입 가능!! | ||
document.write(arguments[3]); | document.write(arguments[3]); | ||
} | } | ||
Revision as of 06:49, 18 January 2011
- 함수
- 중첩함수
- 중첩 함수 예
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);