News for hackers. Stuff that matters.
Re:Writing JavaScript with Only Six Characters by ewendel on Tuesday December 17, 2019 @03:01AM (#21811598)
I don't write alot of blog posts. Appreciate any feedback you might have :)
Re:Writing JavaScript with Only Six Characters by Waterluvian on Tuesday December 17, 2019 @08:17AM (#21813122)
I love it. But I think it cheats a tiny bit by getting a word that requires only characters from "false". It means you're demonstrating the same trick four times.

Maybe you could do a kind of proof:

1. This is how you get any character 2. This is how you call eval() 3. QED

Re:Writing JavaScript with Only Six Characters by herohamp on Wednesday December 18, 2019 @12:40PM (#21827252)
Yeah the ability to get any character would really show more of how this works
Re:Writing JavaScript with Only Six Characters by trehalose on Wednesday December 18, 2019 @01:47PM (#21827899)
Please run simple code to verify accuracy before publishing it.

The unary plus operator coerces undefined to NaN, not to zero as your article states.

The unary plus operator coerces NaN to NaN, not to zero as your article states. (Remember that NaN is already a number, despite its name.)

If you need to coerce any falsy value to 0, the simplest way is to use bitwise operators. If you want to do it the six character way, I guess use Math.imul

Re:Writing JavaScript with Only Six Characters by getcrunk on Tuesday December 17, 2019 @03:20AM (#21811687)
It’s great my guy! Love the recap at the end
Re:Writing JavaScript with Only Six Characters by rsiqueira on Tuesday December 17, 2019 @09:20AM (#21813642)
There's Dwitter, a minimalist JavaScript code community, where we use these kind of tricks to write interesting code, demos and concepts with just 140 characters or less: https://dwitter.net/
Re:Writing JavaScript with Only Six Characters by giancarlostoro on Tuesday December 17, 2019 @09:33AM (#21813777)
This is fascinating! Thanks for the share, I had no idea this even existed. Some of the posts are impressive too. Walther is known for their short reset triggers on their handguns for example.
Re:Writing JavaScript with Only Six Characters by rsiqueira on Tuesday December 17, 2019 @11:05AM (#21814864)
I've just posted a working code on Dwitter based on this "JavaScript with Only Six Characters", it shows 1e+100 turning into Infinity. https://www.dwitter.net/d/16881
Re:Writing JavaScript with Only Six Characters by nchntrz on Tuesday December 17, 2019 @03:40AM (#21811805)
Pretty good explanation. For those who want to dive deeper, there is an esoteric language based on these concepts: http://www.jsfuck.com/
Re:Writing JavaScript with Only Six Characters by matsemann on Tuesday December 17, 2019 @03:38AM (#21811788)
Is there a limit to what one can do with these six characters? Like, now we're reading values from the string "false". We also could read from "true", and maybe undefined (how?). But can one do more? If one can generate "window", one should be able to call functions through window["functionName"]() and do general computing with this, I think?
Re:Writing JavaScript with Only Six Characters by ewendel on Tuesday December 17, 2019 @03:57AM (#21811881)
As I understand, there's no limit to what you can do with these six characters.

It quickly gets more complicated though, and will require alot more code:

"undefined": [][![]]+[] (empty array accessed at index 0 turned into string)

"NaN": +{}

"[object Object][object Object]": {}+{}

.. etc

See the full list here:

https://github.com/aemkei/jsfuck/blob/master/jsfuck.js

Re:Writing JavaScript with Only Six Characters by maury91 on Tuesday December 17, 2019 @03:52AM (#21811859)
you can obtain undefined by accessing the first element of an empty array. `([])[+!![]]`
Re:Writing JavaScript with Only Six Characters by maury91 on Tuesday December 17, 2019 @03:43AM (#21811815)
you can make the final code slightly shorter by obtaining the "e" from "true" instead of "false". `(!![]+[])[+!+[]+!+[]+!+[]]`
Re:Writing JavaScript with Only Six Characters by sveingjoby on Tuesday December 17, 2019 @03:02AM (#21811602)
Great article. I've seen articles about this concept before, but none of these had such a thorough explanation!
Re:Writing JavaScript with Only Six Characters by 74ls00 on Tuesday December 17, 2019 @04:39AM (#21812083)
World’s most unreadable embedded programming language?