zoukankan      html  css  js  c++  java
  • 函数声明与函数表达式

    ddd

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    <body>
    <script>
    //    1.constructor指向不同
    //    var sayHi = function () {
    //
    //    };
    //
    //    function sayHello(){
    //
    //    }
    
    //    console.log(sayHi.prototype);       //constructor指向匿名函数
    //    console.log(sayHello.prototype);    //constructor指向自己
    </script>
    <script>
    //    2.调用顺序
    //    sayHi();      //error!
    //    var sayHi = function () {
    //        alert("Hi");
    //    };
    //
    //    sayHi();        //必须在之后条用
    //
    //    sayHello();     //调用的位置无关紧要
    //    function sayHello(){
    //        alert("Hello");
    //    }
    </script>
    <script>
    //    3.在模拟作用于中,函数表达式是全局的,函数声明是局部的
    //(function () {
    //    sayHi = function () {
    //        alert("Hi");
    //    }
    //
    //    function sayHello(){
    //        alert("Hello");
    //    }
    //
    //})()
    
    //    sayHi();        //alert "Hi"
    //    sayHello();     //error!
    </script>
    </body>
    </html>
  • 相关阅读:
    css浮动
    css各种元素最原始的表现
    css3 unset属性
    js类式继承
    javascript编写Tab选项卡
    javaScript事件冒泡
    javascript中的&&与||的用法
    比较好的前端网站
    原生js开发tab选项卡之闭包
    冒泡排序(中级版)
  • 原文地址:https://www.cnblogs.com/masita/p/5120313.html
Copyright © 2011-2022 走看看