Expected Behavior
Variable assignment without declaration when using object destructuring should work.
According to destructuring assignment in MDN
{a, b} = {a: 1, b: 2} is not valid stand-alone syntax, as the {a, b} on the left-hand side is considered a block and not an object literal.
However, ({a, b} = {a: 1, b: 2}) is valid, as is var {a, b} = {a: 1, b: 2}
Current Behavior
Currently the variable name on left-hand side part of the statement is not being changed by the obfuscator while the initial variable declaration is.
This is the obfuscator output for the function below:
functiontest(_0x4bb6ab){
let_0x44c2ed=undefined;if(!![]){
({
a // <- notice how a is not obfuscated
}=_0x4bb6ab);
}console[_0x1b95('0x0')](_0x44c2ed);
}
Steps to Reproduce (for bugs)
- Simply run the obfuscator for the code example given below
Your Environment
- Obfuscator version used: 0.18.1
- Node version used: 8.2.1 (although it does matter)
Stack trace
Minimal working example that will help to reproduce issue
function test(obj) {
let a = undefined;
if(true){
({a} = obj);
}
console.log(a);
// this should print 1, running the same example after the obfuscation prints undefined
}
test({a: 1});
Expected Behavior
Variable assignment without declaration when using object destructuring should work.
According to destructuring assignment in MDN
Current Behavior
Currently the variable name on left-hand side part of the statement is not being changed by the obfuscator while the initial variable declaration is.
This is the obfuscator output for the function below:
Steps to Reproduce (for bugs)
Your Environment
Stack trace
Minimal working example that will help to reproduce issue