[英]javascript error “SyntaxError: Unexpected token &&”
I was trying to do something like this in console 我正在尝试在控制台中执行类似的操作
var a = {title : '123'}
a && a.title //" 123"
but when I do this I have an error 但是当我这样做时我有一个错误
{title : '123'} && '123'
**ERROR SyntaxError: Unexpected token &&**
I don't understand what conversions V8 did 我不明白V8做了什么转换
The first part is parsed as a block with a label . 第一部分被解析为带有标签的块。 So what follows is the start of a statement.
因此,接下来是声明的开始。
&&
is a binary operator (meaning taking two operands), it can't start a statement. &&
是二进制运算符(表示采用两个操作数),它无法启动语句。
Make the first part an expression by using parenthesis : 使用括号使第一部分成为表达式:
({title : '123'}) && '123'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.