<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title></head><body> <script> //js函数的书写 function myFunction() { console.log("你好"); }//左边是funcion关键字 后面是函数名,里面写表达式//带参数的两种写法 //1.在函数里面写实参 function myFunction(num,time,action) { var num=7,time="点",action="起床"; console.log(num + time + action); }//2.在调用函数的时候写实参 function myFunction(num,time,action) { console.log(num + time + action); } myFunction("7", "点","起床");//带返回值写法 function myFunction(a,b){ var a=5,b=6; return a+b; }//外面接受返回值 function num(a,b) { return c=a+b; } var z=num(7,8); //通过=把return的值获取到 console.log(z); </script> </body></html>