3707人加入学习
(6人评价)
Web前端第三季(JavaScript)

制作完成于2018年6月14日

价格 免费
<!DOCTYPE html>
<head>
    <meta charset="UTF-8">
    <title>函数</title>
    <script type="text/javascript">
        // console.log("数据校验第一步");
        // console.log("数据校验第二步");
        // console.log("数据校验第三步改变");
        // console.log("数据校验第四步");

        // console.log("数据校验第一步");
        // console.log("数据校验第二步");
        // console.log("数据校验第三步改变");
        // console.log("数据校验第四步");

        // console.log("数据校验第一步");
        // console.log("数据校验第二步");
        // console.log("数据校验第三步改变");
        // console.log("数据校验第四步");

        // function myname(){
        //     console.log("我是函数体");
        // }
        // myname();

        datacheck();
        datacheck();
        datacheck();

        //创建一个新的函数(声明函数或者定义函数)
        function datacheck(){
            console.log("数据校验第一步");
            console.log("数据校验第二步改变");
            console.log("数据校验第三步改变");
            console.log("数据校验第四步");
        }
    </script>
</head>
<body>
    
</body>
</html>

什么是函数?
一个函数有自己一个固定的功能,调用函数相当于调用这个功能。
函数有系统内置的函数,我们也可以定义自己的函数,使用这个函数实现我们想要的功能。
在定义函数的时候,我们需要写很多行代码来实现我们想要的功能。
函数可以被多次调用,我们只需要通过函数名调用即可调用响应的功能,这样就避免了每次想要调用某个功能的时候,就去书写重复的代码。

函数的作用:
1,一个函数实现一个固定的功能
2,避免重复写代码

函数怎么调用?
xxx1(arg1,arg2,arg3);
函数名是定义的时候决定的,参数也是定义的时候决定的。我们想要什么功能就必须调用对应名字的函数,并且提供对应的参数。(调用别人的函数的时候,不能自己随便写函数名和参数)
 

[展开全文]

 <script type="text/javascript" >
  var stringl="好好学习,天天向上"
  function:myname{
   console.log("第一步");
   console.log("第二部");
   console.log("第三部");
  }
  myname();
  myname();
//  alert(stringl);
//  alert(stringl);
 </script>

[展开全文]