Why does (![]+[])[+!![]+[]] produce "a"

I am interested in understanding the internals of [JavaScript][1]. I've tried to read the source for [SpiderMonkey][2] and [Rhino][3] but it's quite complex to wrap my head around. The reason I ask is: why does something like - `(![]+[])[+!![]+[]]` produce `"a"` - `(Å=[],[µ=!Å+Å][µ[È=++Å+Å+Å]+({}+Å)[Ç=!!Å+µ,ª=Ç[Å]+Ç[+!Å],Å]+ª])()[µ[Å]+µ[Å+Å]+Ç[È]+ª](Å)` produce `alert(1)`? Source: http://sla.ckers.org/forum/read.php?24,32930,page=1. There's many more examples of JavaScript oddities on that forum and I wanted to know how it works from a programming point of view with respect to web application security. [1]: http://en.wikipedia.org/wiki/JavaScript [2]: http://en.wikipedia.org/wiki/SpiderMonkey_%28JavaScript_engine%29 [3]: http://en.wikipedia.org/wiki/Rhino_%28JavaScript_engine%29
if you are interested in how languages work, nothing beats writing a compiler for it yourself - that will basically teach you the language, and its internals.

以上就是Why does (![]+[])[+!![]+[]] produce "a"的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准