1. 程式人生 > >js函數及函數的基本調用

js函數及函數的基本調用

res nbsp js函數 結果 result 1+n bsp ons ()

1.基本語法

栗子:

<script>

function sayhello(){

console.log("hello");

}

sayhello();//函數調用

</script>

2.帶參函數

<script>

function myfunction(num1,num2){

var result=num1+num2;

alert(result);

}

mufunction(2,2);//彈出結果4

</script>

js函數及函數的基本調用