为什么javascript中的(([] === [])+ / - /)[1] ='a'和(1 + {})[(1<< 1)+1] ='b'? [英] Why is (([]===[])+/-/)[1] = 'a' and (1+{})[(1<<1)+1] = 'b' in javascript?

查看:76
本文介绍了为什么javascript中的(([] === [])+ / - /)[1] ='a'和(1 + {})[(1<< 1)+1] ='b'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我遇到了一个有趣的网站,它说明了一个Javascript Obfuscator: http://bl.ocks.org / jasonsperske / 5400283

Recently I came across an interesting website that illustrates a Javascript Obfuscator: http://bl.ocks.org/jasonsperske/5400283

例如,(([] === [])+ / - /)[1] 给出 a (1 + {})[(1<< 1)+1] 给出 b

我努力理解这些混淆结果的评估顺序但是在徒劳。

I have tried hard to understand the evaluation sequence of these obfuscated result but was in vain.

(1 + {})[(1<<< 1)+1] 作为例如,我理解<< 是按位移位运算符并将返回2,因此表达式变为(1 + {})[3 ] 。但后来我无法理解 1 + {} [3] 是什么意思。

Taking (1+{})[(1<<1)+1] as an example, I understand that << is the bitwise shift operator and will return 2, so the expression becomes (1+{})[3]. But then I cannot understand what does it mean by 1+{} and [3].

谷歌对这个问题并没有多大帮助,因为搜索引擎不喜欢括号或斜线,所以万一有重复的问题我很抱歉那个。

Google isn't really helpful to this problem as search engines don't like the brackets or slashes very much, so in case there are duplicate questions I'm sorry about that.

推荐答案

这只是混淆技巧。

例如:

[] === [] ===> false

([] === [])+ / - / ===> false / - /(你可以自己在控制台中测试它)

([]===[])+/-/ ===> "false/-/" ( You could test it in the console by yourself)

那么什么是(([] === [])+ / - /)[1] ? (第二个字符)

So what is (([]===[])+/-/)[1] ? ( second char)

这是正确的:'a'

可能想要另外看一下:

这篇关于为什么javascript中的(([] === [])+ / - /)[1] ='a'和(1 + {})[(1&lt;&lt; 1)+1] ='b'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆