Syntax error with ES6 shorthand properties
See original GitHub issueThe following input file (test.js
) contains shorthand properties:
let a = 23;
let b = 42;
exports.o = {a, b};
Node.js can handle them:
$ node --version
v6.6.0
$ node
> require('./test.js')
{ o: { a: 23, b: 42 } }
However, loading the obfuscated file raises a syntax error:
$ javascript-obfuscator test.js --output obfuscated.js
$ node
> require('./obfuscated.js')
/home/ralf/git/test/obfuscated.js:1
(function (exports, require, module, __filename, __dirname) { var _0x8065=['\x6a\x6f\x69\x6e','\x73\x70\x6c\x69\x74'];(function(_0x18a2d3,_0x168483){var _0x427e21=function(_0x18c5bd){while(--_0x18c5bd){_0x18a2d3['\x70\x75\x73\x68'](_0x18a2d3['\x73\x68\x69\x66\x74']());}};(function(){var _0x655c94=function(){return'\x64\x65\x76';};!Function('\x72\x65\x74\x75\x72\x6e\x2f\x5c\x77\x2b\x20\x2a\x5c\x28\x5c\x29\x20\x2a\x7b\x5c\x77\x2b\x20\x2a\x5b\x27\x7c\x22\x5d\x2e\x2b\x5b\x27\x7c\x22\x5d\x3b\x3f\x20\x2a\x7d\x2f')()['\x74\x65\x73\x74'](_0x655c94['\x74\x6f\x53\x74\x72\x69\x6e\x67']())?[]['\x66\x69\x6c\x74\x65\x72']['\x63\x6f\x6e\x73\x74\x72\x75\x63\x74\x6f\x72']((+0x20)['\x74\x6f\x53\x74\x72\x69\x6e\x67'](0x21)+(+0x65)['\x74\x6f\x53\x74\x72\x69\x6e\x67'](0x15)[0x1]+([![]]+undefined)[0xa]+(![]+'')[0x2]+(!![]+'')[0x3]+'\x28\x74\x72\x75\x65\x29\x7b\x7d')():Function('\x61','\x62','\x61\x28\x2b\x2b\x62\x29')(_0x427e21,_0x168483)?[]['\x66\x69\x6c\x74\x65\x72']['\x63\x6f\x6e\
SyntaxError: Unexpected token ,
After replacing the shorthand properties in test.js
with {a: a, b: b}
, things work fine.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
What is JavaScript shorthand property? - Stack Overflow
With ES6, you can use shorthand property names which allow you to write something like this. var s = 'abc'; var n =...
Read more >object-shorthand - ESLint - Pluggable JavaScript Linter
"never" ensures that no property or method shorthand is used in any object literal. "consistent" ensures that either all shorthand or all long-form...
Read more >Why SyntaxError: Invalid shorthand property initializer - SitePoint
I got this error message “SyntaxError: Invalid shorthand property initializer” and I don't see invalid notation but just a working code ...
Read more >Shorthand Syntax for Object Property Value in ES6
The shorthand syntax for object property value is very popular and widely used nowadays. The code looks cleaner and easy to read.
Read more >Object initializer - JavaScript - MDN Web Docs - Mozilla
The property name must be double-quoted, and the definition cannot be a shorthand. Computed property names are not allowed either.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
0.7.2 is out. Now - its time to fix and update plugin for webpack.
Nice, i should fix strange decreasing of tests code coverage and then i will release it on npm