wtf js(一)


var Z = "constructor";

Z[Z][Z]("alert('wtf js!')")();

// alert wtfjs!

点解?发生什么了?

Z[Z]

//  function String(){[native code]}

Z[Z][Z]

// function Function(){[native code]}

解释:

Z[Z]-->string["constructor"]-->String

Z[Z][Z]-->String["constructor"]-->Function

So:

Z[Z][Z]("alert('wtf js!')")();

-->

(function Function(){alert('wtf js!')})();

原文地址:https://www.cnblogs.com/myself/p/1764348.html