zoukankan      html  css  js  c++  java
  • 匿名函数

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>匿名函数</title>
    <!--了解匿名函数的定义
    了解匿名函数的调用
    理解匿名函数的作用
    理解调用运算符“()”的作用-->
    </head>
    <body>
    <script type="text/javascript">
    /* function run(){
    return 100;
    }
    document.write(run());
    document.write("<br />")
    document.write(run);
    run(); 了解运算符()的作用,此处输出为:100
    function run(){ return 100; }*/


    /* 匿名函数的创建于调用*/
    var noneName=function(){
    document.write("调用匿名函数1<br />")
    }
    noneName();

    (function(){
    document.write("调用匿名函数2")
    })();



    输出: 调用匿名函数1
    调用匿名函数2
    </script>
    </body>
    </html>

    函数名是函数对像地址的引用

    “()运算符的作用是开始调用函数,也就是执行内存中的函数体,()内可加载参数。jsp中,函数调用的形式为:函数地址+(参数)

    (function(){

    })这样的风格也满足:函数地址+(参数)的格式

  • 相关阅读:
    每日签到
    手机刮刮卡
    js随机更换
    jquery实现input输入框实时输入触发事件代码
    webAPP前端必备知识
    让你分分钟学会 JS 闭包
    js获取url?后的参数
    js获取上传的文件名
    Javascript 中神奇的 this
    由浅入深完全掌握Ajax
  • 原文地址:https://www.cnblogs.com/wxhhts/p/7743402.html
Copyright © 2011-2022 走看看