function if ( x, y, z )
(方法名称关键字) (方法名) (参数)
{
alevt(x*y*z);
}
fi(1,2,3)
例子1:
function tankuang ( )
{alevt("H")}等价于var tankuang=function( ){alevt("H")}
例子2:
function jiafa(a,b){return a+b;} 等价于var jiafa=function(a,b){return a+b;}
jiafa(有名字的方法(非匿名),名字叫jiafa
function(a,b) (匿名方法,拿"jiafa"这个变量指向
例子3:
var jieguo=jiafa(1+2);
alevt(jieguo)
等价于alevt(jiafa(1+2)); (相当于两步写成一步)
例子4:
function tankuang( ){..........}
var a1=domcument.GetElement(By id("a1")
a1.onclick(tankuang); (onclick这个函数就是要传入一个方法的变量名)
等价于
domcument.GetElement(By id("a1").onclick
function ( ){..........}
时间: 2024-09-30 20:38:17