読んでみた!JavaScript の概要!その18

Predefined Core Objects - JavaScript | MDN functionオブジェクト


Function オブジェクト

var functionObjectName = new Function([arg1, arg2], functionBody);

//関数を変数に代入 ''' var setBgColor = new Function("document.bgColor = 'antiquwhite'"); '''

//関数を宣言 ''' function setBgColor () { document.bgColor = 'antiquewhite'; } '''

関数は入れ子にできる。内部の関数は外部の関数に対してプライベート。 内部の関数は外側の関数からしかアクセスできない。 内部の関数は外側の関数の引数や変数を使える!でも外側の関数は内部のかん関数の引数や変数は使えない!