Have you ever seen variables defined like this in JavaScript?

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?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值