ericwlange/AndroidJSCore

JavaScript Syntax error

Closed this issue · 2 comments

Hi, I have a large js file(which I use for iOS JavaScriptCore without any issue) to load into JSContext, and it throws JSException like "unexpected script end". There is no more information I can find such as which line and what exactly is missing.

That generally implies that there is a mismatched closing quote, brace, bracket or paren somewhere. As you haven't posted the code, I can't debug it. One suggestion: open a node console and see if it loads correctly.

machine:~ me$ cd /path/to/js/file
machine:~ me$ node
> var code = String(fs.readFileSync('file.js'))
> eval(code)

If the last line executes without throwing an exception, the file is probably fine. It's a good check to see if iOS JavaScriptCore is ignoring something.

The other possibility is that you are using some ES6 extensions to JavaScript. Later versions of iOS may support it. AndroidJSCore is using only an ES5 compliant version of JS at the moment.

Thanks that method helps.
I use minified JavaScript files and it can get ride of all the syntax errors.