为什么“{} == {}"?导致语法错误? [英] Why does "{} == {}" result in a SyntaxError?
本文介绍了为什么“{} == {}"?导致语法错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能的重复:
为什么在 JavaScript 中使用 {} != ( {} )?
我今天试过了,它今天给我带来了SyntaxError,这让我感到奇怪;这有什么问题吗?
I tried it today and it threw me SyntaxError today and it made me wonder; what's wrong with this?
{} === {}
{} == {}
怎么了?
推荐答案
当 {
是一行中的第一个标记时,它被认为是块的开始.
When {
is the first token in a line, it's considered the start of block.
{
some();
statements();
here();
}
而不是对象字面量.代码块不能等于任何东西,它不是可赋值的东西.
And not an object literal. A block of code cannot be equal to anything, it's not an assignable thing.
({}) === {}
这将直接设置解析器.
这篇关于为什么“{} == {}"?导致语法错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文