天天看點

js 函數的陷阱

function test(){

return "hello";

}

alert(test);這個顯示是變量test的值,它正好是個函數,這是第一個警告對話框顯示的結果:

alert(test());

圓括号()告訴它執行函數test,并顯示它的傳回值,就像下面這樣:

hello;

function addInput(name,value){

do something;

alert(addInput);

var testCall=addInput;

testCall(‘name‘,‘value‘);

他們指向同一個函數。

x[i].onkeyup=x[i].onchange=checkMaxLength;