Live data from Hacker News

JSFuck – esoteric JavaScript

jsfuck.com

11–20 of 39 posts

Re: JSFuck – esoteric JavaScript

#13
post #10

I know this will most likely come as a surprise to most Javascript programmers but all code is represented using only two "characters" deep inside your little computers!

Most JavaScript developers have tiny computers.

Re: JSFuck – esoteric JavaScript

#16
It was on HN 2 years ago with some interesting comments: "JSFuck – Write any JavaScript with 6 Characters: []()!+": https://news.ycombinator.com/item?id=6379732

One interesting question was about the "performance impact"? One reply was: "Vanilla I got 225k ops/sec. JSFuck, 4.5 ops/sec. So about 50000 times slower."

Re: JSFuck – esoteric JavaScript

#19

For those wondering how you get numbers, strings and other primitives from a whole bunch of empty arrays and objects in JavaScript, here's what happens when you do arithmetic and other operations on arrays and objects: > [] + [] "" (An empty string) > {} + [] 0 (The number zero) > [] + {} "[object Object]" (.toString() called on a plain object). > ![] false (!{} is the same) > !![] true (not false) > +[] 0 (the numbe…

Does knowing any of this make you a better programmer? I'd say no.

Should you be using any of this in production code? No

The next programmer even if he is a really good one might not know that particular esoteric trick.

I'm not trying to vote down or anything, but what is the point? Most of it look like language design warts to me. Most of them should have thrown exceptions and errored out.

Now I'm loving the idea of static typing a lot more.

Re: JSFuck – esoteric JavaScript

#20

For those wondering how you get numbers, strings and other primitives from a whole bunch of empty arrays and objects in JavaScript, here's what happens when you do arithmetic and other operations on arrays and objects: > [] + [] "" (An empty string) > {} + [] 0 (The number zero) > [] + {} "[object Object]" (.toString() called on a plain object). > ![] false (!{} is the same) > !![] true (not false) > +[] 0 (the numbe…

Does knowing any of this make you a better programmer? I'd say no. Should you be using any of this in production code? No The next programmer even if he is a really good one might not know that particular esoteric trick. I'm not trying to vote down or anything, but what is the point? Most of it look like language design warts to me. Most of them should have thrown exceptions and errored out. Now I'm loving the idea o…

Useful for obfuscating executable JS for security reasons.
Post reply on HN