const在Edge 15开发人员工具中不起作用 [英] const doesn't work in Edge 15 developer tools

查看:107
本文介绍了const在Edge 15开发人员工具中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Edge / 15.15063。



为什么const不工作​​?

解决方案

我怀疑Edge控制台在其封面下使用语句像其他实现一样做了 。这将解释 var s和甚至函数声明被提升到全局范围之外,但 const 将被锁定进入区块范围:

  with(...){
const x ='woo'
}
//下一个输入:
with(...){
console.log(x)//显然未声明
}

尝试在单线评估中以多线模式输入 - 他们应该在那里工作。



但你也是可能想要提交一个错误,因为控制台确实希望感觉就像评估全局范围内的东西一样。


I am running Edge/15.15063. 'Can I Use' says const should work.

Running:

const x = 'woo'

Then:

console.log(x)

Returns

'x' is undefined

Screenshot:

Why isn't const working?

解决方案

I suspect that the Edge console is using a with statement under its covers like other implementations did. This would explain vars and even function declarations being hoisted outside into the global scope, but let and const will be locked into the block scope:

with (…) {
    const x = 'woo'
}
// next input:
with (…) {
    console.log(x) // obviously undeclared
}

Try entering them in multiline mode, in a single evaluation - there they should work.

But you also might want to file a bug, as the console is indeed expected to feel like evaluating things in the global scope.

这篇关于const在Edge 15开发人员工具中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆