Created
March 28, 2013 07:04
-
-
Save tychio/5261256 to your computer and use it in GitHub Desktop.
a javascript puzzle , and try to work out the alert result
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var output1 = new Array; | |
| var output2, output3; | |
| var pushArr = function (c) { | |
| if (!c) { | |
| c = 0; | |
| } | |
| output1.push(c); | |
| }; | |
| var a = 1; | |
| pushArr(a); | |
| var d = (function (a) { | |
| pushArr(a); | |
| var a = 2; | |
| pushArr(a); | |
| var b = function () { | |
| pushArr(a); | |
| var a = 3; | |
| pushArr(a); | |
| return function (a) { | |
| pushArr(a); | |
| var a = 4; | |
| pushArr(a); | |
| } | |
| } | |
| pushArr(a); | |
| a = b()(a); | |
| pushArr(a); | |
| return function () { | |
| pushArr(a); | |
| a = 5; | |
| pushArr(a); | |
| return a; | |
| }; | |
| })(a); | |
| pushArr(a); | |
| a = d(); | |
| pushArr(a); | |
| output2 = output1.slice(0); | |
| output3 = output1; | |
| output3.sort(function (a, b) { | |
| return a - b; | |
| }); | |
| var al = function () { | |
| alert(output1.slice(a).concat(output2, output3.slice(0-a)).join("")); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment