mqyqingfeng / Blog

冴羽写博客的地方,预计写四个系列:JavaScript深入系列、JavaScript专题系列、ES6系列、React系列。
30.53k stars 4.7k forks source link

关于执行上下文VO的一些疑问,求解答 #282

Open agreenbird1 opened 2 years ago

agreenbird1 commented 2 years ago
 function f(x) {
    console.log(x) // 5
    var x
    console.log(x) // 5
  }
  console.dir(f)
  f(5)

其实这个如果形参和声明的变量重复的话,按照输出的意思是

VO:{
    arguments:{
       '0':  x
    },
    x
}

然后变量x的声明是将形参的声明覆盖了然后传递参数将其赋值为5的吗? 可能没描述清楚问题,大概意思就是变量的声明同名情况下与形参的关系。 谢谢

mqyqingfeng commented 2 years ago

变量声明与形参同名的情况下……我忘了……有人能帮我解答一下吗 😂

czj2017 commented 2 years ago

范德萨范德萨 ------------------ 原始邮件 ------------------ 发件人: "mqyqingfeng/Blog" @.>; 发送时间: 2022年4月10日(星期天) 晚上11:00 @.>; @.***>; 主题: Re: [mqyqingfeng/Blog] 关于执行上下文VO的一些疑问,求解答 (Issue #282)

羽哥球球了

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

czj2017 commented 2 years ago

123

---原始邮件--- 发件人: @.> 发送时间: 2022年4月10日(周日) 晚上10:48 收件人: @.>; 抄送: @.***>; 主题: [mqyqingfeng/Blog] 关于执行上下文VO的一些疑问,求解答 (Issue #282)

function f(x) { console.log(x) // 5 var x console.log(x) // 5 } console.dir(f) f(5)

其实这个如果形参和声明的变量重复的话,按照输出的意思是 VO:{ arguments:{ '0': x }, x } 然后变量x的声明是将形参的声明覆盖了然后传递参数将其赋值为5的吗? 可能没描述清楚问题,大概意思就是变量的声明同名情况下与形参的关系。 谢谢

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>