zoukankan      html  css  js  c++  java
  • 范仁义js课程---52、匿名函数

    范仁义js课程---52、匿名函数

    一、总结

    一句话总结:

    匿名函数也就是没有名字的函数,可以通过加圆括号的方式调用,和有名字的函数的调用方式一致
    (function (a) {
        console.log('你好');
        console.log(a);
    })(10);

    二、匿名函数

    博客对应课程的视频位置:52、匿名函数
    https://www.fanrenyi.com/video/19/153

     1 <!DOCTYPE html>
     2 <html lang="en">
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>匿名函数</title>
     6 </head>
     7 <body>
     8 <!--
     9 匿名函数:没有名字的函数
    10 
    11 把匿名函数对象放进了一对小括号,避免报错
    12 
    13 匿名函数的调用:
    14 直接在匿名函数后面加上小括号,如果有参数,就写在小圆括号里面
    15 
    16 函数名本身代表的就是函数的 函数体
    17 
    18 
    19 
    20 -->
    21 <script>
    22     // function fun1() {
    23     //     console.log('你好');
    24     // }
    25     // fun1();
    26     // console.log(fun1);
    27 
    28     // (function () {
    29     //     console.log('你好');
    30     // })();
    31 
    32     (function (a) {
    33         console.log('你好');
    34         console.log(a);
    35     })(10);
    36 
    37 
    38 </script>
    39 </body>
    40 </html>
     
  • 相关阅读:
    HDU 2586 How far away?
    UVAlive 5796 Hedge Mazes
    HDU 4975 A simple Gaussian elimination problem.
    Poj 1149 PIGS
    HDU 3416 Marriage Match IV
    HDU 4912 Paths on the tree
    HDU 3277 Marriage Match III
    終於記起了帳號密碼
    codeforces194a
    codeforces195c
  • 原文地址:https://www.cnblogs.com/Renyi-Fan/p/12438879.html
Copyright © 2011-2022 走看看