Typically, in JS, variables are defined using var, let, or const.
For example: var abc = 1;
But what if you don't want others to see that you've defined a variable abc? How should you do it?
You can write it like this: this["abc"] = 1;
This also defines a variable abc.
Huh? Can you write it like this? Yes, you can! Don't believe it? Just run a test to find out.
But this still reveals the abc string and shows that the assigned value is the number 1. Is there a way to make it even more obscure?
Yes, you can also use JS-Obfuscator.com to obfuscate this line of code.
After obfuscation, this["abc"] = 1; will become:
this["\u0061\u0062\u0063\u0064"] = 0x3ba17 ^ 0x3ba16;
At this point, if you use console.log(abc) or alert(abc), you will see that the value 1 of the variable abc is output.
However, at a glance, neither the variable abc nor the number 1 is immediately visible in this line of code.
Isn't that interesting?
Have you learned this JS programming trick?
Top comments (0)