前端预编译流程

  前言

0aded3c596e556616cc9705a0caf79cb.png

 我是歌谣 最好的种树是十年前 其次是现在 今天继续给大家带来的是预编译基础的讲解

 环境配置

c111415f2ee29e7e3b3ff1dd7f5e63e7.png

npm init -y
yarn add vite -D

 修改page.json配置端口

b3488e63568bdb36180c3860a14247fe.png

{
  "name": "demo1",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "vite --port 3002"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "vite": "^4.4.9"
  }
}

 案例1

22b380595e18c6abcdec24a99611a6e8.png

var a=1
b=1
console.log(window.a)
window={
    a:1,
    b:2
}

运行结果

d85e29e2fc4050e2d8495deb9673348e.png

d9307524b76b8604fb35b81f0cec2d8e.png

 案例2

c228e8ef857894cefb298b80fa612921.png

function test(){
    var a=b=1
}
test()
console.log(window.a)
console.log(window.b)

 运行结果

a8c4e839fec0cefda6f60a2ee0893f2d.png

8679c659f7844c628da7d4ca9732af46.png

 案例3

769cc839b7292454551410d53a0130bd.png

function test(a){
    console.log(a)
    var a=1
    console.log(a)
    function a(){




    }
    console.log(a)
    var b=function(){}
    console.log(b)
    function d(){




    }
}
//AO
//AO={
//   a:undefined->2->function a(){}->1
//   b:undefined->function b(){}
//   d:function d(){}
//}
//
test(2)

 运行结果

e0834973dd9eea1561900a9c6e582dc5.png

7956252703681865ad86d1c00fda85ac.png

 案例4

8d0985fe3689e33adbdbc8bcbc04fbab.png

function test(a,b){
    console.log(a)
    c=0
    var c;
    a=5;
    b=6;
    console.log(b)
    function b(){}
    function d(){}
    console.log(b)
}
test(1)
// AO{
//    a:undefined-->a-->5
//    b:undefined-->function b(){}-->6
//    c:undefined-->0
//    d:function d(){}
//}

运行结果

f37152c154c65f4dcc960426d1bd3ef2.png

fb8346d495e053410fdeb944ea403c89.png

 案例5

3a4d5d21efcc33c03e129385db689162.png

var a=1;
function a(){
    console.log(2)
}
console.log(a)
// GO{
//  a:undefined-->function a(){}--->1
//
//}

 运行结果

e99a9bfc7c9e8b5f468dc8bb69476f07.png

286278377151d861d34160f4b1de5f9e.png

案例6

d66e75b264cc63675750342fe49afb7f.png

console.log(a,b)
function a(){}
var b=function(){}
// GO{
//  a:undefined---->function a(){}
//  b:a:undefined
//}

 运行结果

78465674e1304920aadfc2c420859ac4.png

f74327cd62515a6343fd56b45daf016d.png

案例7

d562d51ff05c3012f6944c8c6b19960a.png

function test(){
    var a=b=1;
    console.log(b)
}
test()
//GO={
//  b:1
//}
//AO{
//  a:undefined--->1
//}

 运行结果

d3d3158bd29faafe9a7cf5c573be4187.png

c515c414cd8cdf253c22bbdce287ac79.png

 案例8

a23a8c9be9e61343a612b0a796d30c69.png

var b = 3
console.log(a)
function a(a) {
    console.log(a)
    var a = 2;
    console.log(a)
    function a() {
    }
    var b = 5;
    console.log(b)
}
a(1)




//AO{
//   a:undefined--->1---->function a()--->2
//   b:undefined--->5
//
//}
//GO{
//   b:undefined--->3
//   a:function a(){}
//}

 运行结果

785e7390978ee3fc695383dbdf53202f.png

c6f41b6b21c3315dfb48f27430f9370d.png

案例9

8d2876f48e6af628d6ebb0dcaaf0fbab.png

a=1
function test(){
    console.log(a)
    a=2
    console.log(a)
    var a=3
    console.log(a)
}
test()
var a;
//GO{
//  a:undefined--->1
// test:function test(){}
//}
//AO{
//  a:undefined--->2--->3
//
//}

 运行结果

b06ec3efb1f10b924619a77978410af9.png

60abd94a0bb902249435f0846ab9e8a7.png

 案例10

63f1de1ee638b25a783ff2840f609fed.png

function test(){
    console.log(b)
    if(a){
        var b=2
    }
    c=3;
    console.log(c)
}
var a;
test()
a=1
console.log(a)
// AO{
//   
//    b:undefined-->2
//    
//}
//GO{
//   a:undefined-->1
//   test:function test(){}
//   c:3
//}

 运行结果

b4ebbae8d19b35a3be4958d4c2443ecc.png

36ca99d7eabbfb67019ef9d29a875f89.png

 案例11

66e1cda6809e6c728b6a5c19c161e1d8.png

function test(){
    return a;
    a=1;
    function a(){




    }
    var a=2
}
console.log(test())
// AO{
//    a:undefined---->function a(){}
//
//}
//

 运行结果

773de05d678c4c2c5e419dcbac4fbe27.png

e1c141cc9e760f385643d21ea2eab189.png

 案例12

0103c0bf757fdb8f75f5ba1cb3606e24.png

console.log(test())
function test(){
    a=1
    function a(){




    }
    var a=2
    return a
}




//AO{
//  a:undefined--->function a(){}-->1--->2
//
//
//}
//

 运行结果

9f842e8c1073653c301eaed659cc4881.png

8599904be6749e332882b639e46f5d1d.png

 案例13

61fd9f33c9489fad8f97c1052f4161ef.png

a=1
function test(e){
    function e(){}
    arguments[0]=2
    console.log(e)
    if(a){
        var b=3
    }
    var c;
    a=4;
    var a;
    console.log(b)
    f=5
    console.log(c)
    console.log(a)
}
var a;
test(1)
console.log(a)
console.log(f)
//GO{
//  a:undefined-->1
//   test:function test(){}
//   f:5
//}
//AO{
//   e:undefined---->1---->function e(){}--->2
//   b:undefined
//   c:undefined
//   a:undefined---->4
//}

 运行结果

5ee457b1ce16934ec989ceec2efc9151.png

8c6089d919f0782f6cad5455aaf9a124.png

我是歌谣 想加入前端巅峰人才交流群私信我

下方查看历史文章

f64acf4b9a58aba60a011c052370f454.png

递归

函数参数默认值

函数基础

caller和caller

this指向

对象属性的遍历

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值