zoukankan      html  css  js  c++  java
  • 预解析

          // 1. 我们js引擎运行js 分为两步:  预解析  代码执行
            // (1). 预解析会把js 里面所有的 var  和 function 提升到当前作用域的最前
            // (2). 代码执行  按照代码书写的顺序从上往下执行
          // 2. 预解析分为 变量预解析(变量提升) 和 函数预解析(函数提升)
            // (1) 变量提升 就是把所有的变量声明提升到当前的作用域最前面  不提升赋值操作
            // (2) 函数提升 就是把所有的函数声明提升到当前作用域的最前面  不调用函数
    
             f1();
            console.log(c);
            console.log(b);
            console.log(a);
            function f1() {
                var a = b = c = 9;
                console.log(a);
                console.log(b);
                console.log(c);
            }
    
            //相当于执行以下代码
            function f1() { //提升到作用域最前
    var a; //提升到作用域最前 a = b = c = 9;
    // 相当于 var a = 9; b = 9; c = 9; b 和 c 直接赋值 没有var 声明 当 全局变量看 // 集体声明 var a = 9, b = 9, c = 9; console.log(a); console.log(b); console.log(c); } f1(); console.log(c); console.log(b); console.log(a);
  • 相关阅读:
    2019.1.5JavaScript
    SQL常用删改增语句
    PHP连接数据库
    PHP数组函数
    PHP字符串常用函数
    PHP 类型判断方法
    jQuery效果
    jQuery特性
    倒计时
    判断浏览器及其内核
  • 原文地址:https://www.cnblogs.com/sangejava/p/13066769.html
Copyright © 2011-2022 走看看