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
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
Share Improve this question asked Mar 16, 2014 at 19:48 wrtwrt 211 silver badge4 bronze badges1 Answer
Reset to default 5The 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'
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745459742a4628651.html
评论列表(0条)