Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upObject literal throws parse error #709
Comments
This comment has been minimized.
This comment has been minimized.
|
Oops, actually its not a valid JavaScript file. It needs to be ({a: 1}) with
parenthesis because the curlies will otherwise mean a block statement
instead of an object literal. You can try this out with a JavaScript parser demo here: http://esprima.org/demo/parse.html
|
This comment has been minimized.
This comment has been minimized.
feross
closed this
Dec 5, 2016
This comment has been minimized.
This comment has been minimized.
maxlath
commented
Jan 1, 2017
•
|
for the record, the same issue seems to arise with object destructuring assignment:
var { ids, languages, props, format } = obj
var ids, languages, props, format
{ ids, languages, props, format } = obj // Parsing error: Unexpected token =
var ids, languages, props, format
({ ids, languages, props, format }) = obj |
lock
bot
locked as resolved and limited conversation to collaborators
May 10, 2018
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
futurist commentedDec 4, 2016
Below code will throw Parse Error:
Throws:
But it's valid javascript code.
It's important for this issue, since some times a JS file only store data, to feed other JS to read.