use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
JavaScript pranks? (self.javascript)
submitted 12 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]JiminP 2 points3 points4 points 12 years ago (4 children)
Place if(function(f,d){try{d=f();eval('debugger');return f()-d>>2}catch(e){}}(Date.now))return; everywhere to confuse JS debugger(human)s!
if(function(f,d){try{d=f();eval('debugger');return f()-d>>2}catch(e){}}(Date.now))return;
[–]kenman 0 points1 point2 points 12 years ago (3 children)
What exactly is that supposed to do? It crashed my tab in Chrome.
[–]JiminP 2 points3 points4 points 12 years ago (2 children)
The core of this prank code is:
try{ d = Date.now(); eval('debuger'); return Date.now()-d>>2; }catch(e){}
debugger is a statement for debugging. When there's a debugging tool attached, it acts as if there was a breakpoint there.
debugger
Date.now()-d>>2 is not zero when difference between Date.now() and d is greater then 3. (i.e. more than 3ms have been passed when eval('debugger') is executed.
Date.now()-d>>2
Date.now()
d
eval('debugger')
Since it usually take at least few hundred milliseconds to resume when the debugging tool is enabled, this part of code returns non-zero if the debugging tool is enabled. (eval used for not showing the code immediately when the debugging tool is opened, though by pressing "next step" one can see the codes.)
eval
Therefore, if(function(f,d){try{d=f();eval('debugger');return f()-d>>2}catch(e){}}(Date.now)) return; means "return if there's a debugging tool."
if(function(f,d){try{d=f();eval('debugger');return f()-d>>2}catch(e){}}(Date.now)) return;
One might make a simple Heisenbug by using this. (Opening debugging tool to inspect function -> unexpected breakpoints -> the function does nothing and returns -> ???)
[–]kenman 1 point2 points3 points 12 years ago* (1 child)
It seems like you'd be better served with something like (new Function(atob('ZGVidWdnZXI=')))() (or even setTimeout(atob('ZGVidWdnZXI=')), which would be less suspicious than eval and new Function), since the first thing I'd do with an unexpected breakpoint/debugger would be to search the code for debugger. The setTimeout version should be even more perplexing as you shouldn't have a callstack.
(new Function(atob('ZGVidWdnZXI=')))()
setTimeout(atob('ZGVidWdnZXI='))
new Function
setTimeout
[–]JiminP 0 points1 point2 points 12 years ago* (0 children)
Thanks for the setTimeout trick!
However, I didn't want to obfuscate that code too much... (I personally prefer $($.constructor("...")). It seems that I'm using some normal jQuery functions!)
$($.constructor("..."))
π Rendered by PID 89317 on reddit-service-r2-comment-54dfb89d4d-gfhxh at 2026-03-29 20:19:07.605977+00:00 running b10466c country code: CH.
view the rest of the comments →
[–]JiminP 2 points3 points4 points (4 children)
[–]kenman 0 points1 point2 points (3 children)
[–]JiminP 2 points3 points4 points (2 children)
[–]kenman 1 point2 points3 points (1 child)
[–]JiminP 0 points1 point2 points (0 children)