JavaScript ?? ??
?? ??
??? ?? ?? ??? ????? "??"?? ??? ?????.
??? ? ? ???? ?? ? ??? ? ????.
??? ????? ???? ?? ??? ???? ? ????. ?: ??? ?? ??, ?? ?? ??, ??? ??, ??? ?? ??
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script> function max(a,b){ if(a>b){ document.write(a+"比較大<br/>"); }else{ document.write(b+"比較大<br/>"); } } max(10,50); max(0,100); max(-1,2); max(100,100); </script> </head> <body> </body> </html>
?? ?? ??
function functionName([參數(shù)1][,參數(shù)2][,參數(shù)N]){ 函數(shù)的功能代碼; [return 參數(shù)r] }
?? ?? ?? ??
?? ???? ???? ?? ??????.
functionName: ??? ?????. ?? ??? ?? ??? ?? ?? ??? ?????.
() : ?? ??? ???? ?? ???????. ????? ?????? ?? ????? ??? ?????.
?? ????(?? ????): ??? ??? ? ???? ????? "?? ????"???. ?? ?? ???? ??? ???? ???? ? ?????.
?? ????? ??? ?? ?? ??? ?????.
??? ?? ????? "var" ???? ??? ? ????.
????? ???? ??? ? ????.
????? ??? ?? ?? ?? ??? ? ????.
?? ????(actual paramter): ??? ??? ?? ????? "?? ????"?? ???. ?? ????? ?? ??????.
{}? ??? ?????.
return ?? ?? ????? ?? ???? ??? ?? ???? ? ?????.
return? ?? ??? ???? ? ?????.
break? ??? ??? ???? ? ?????.
?? ??
?? ??? ???? ????. ??? ???? ??? ?????.
?? ?? : ???? ?? ??, ?? ??()? ??, ????? ??? ????? ?????. ??? ??? ? ????.
??? ????
?? ????? ??? ??? ??? ???. ?? ???? ??? ?????.
?? ????? ??? ?? ????? ??? ???? ???.