Seems like it would be interesting to use as a cheap form of JS obfuscation.
JSFuck – Write any JavaScript with 6 Characters: []()!+
11–20 of 76 posts
Re: JSFuck – Write any JavaScript with 6 Characters: []()!+
#12For a little bit of insight into why []+[] === '', for example, check this out: http://www.2ality.com/2012/01/object-plus-object.html
Re: JSFuck – Write any JavaScript with 6 Characters: []()!+
#13Then why does it still translate to 1128 characters? :/
Re: JSFuck – Write any JavaScript with 6 Characters: []()!+
#14Re: JSFuck – Write any JavaScript with 6 Characters: []()!+
#15I put in alert('hello') and it worked. That's awesome. But how? I searched the code it made and didn't see 'hello.' I understand the stuff below, how it uses JS's weird properties to the basic types... but how does it encode characters?
Re: JSFuck – Write any JavaScript with 6 Characters: []()!+
#16I put in alert('hello') and it worked. That's awesome. But how? I searched the code it made and didn't see 'hello.' I understand the stuff below, how it uses JS's weird properties to the basic types... but how does it encode characters?
Re: JSFuck – Write any JavaScript with 6 Characters: []()!+
#17I put in alert('hello') and it worked. That's awesome. But how? I searched the code it made and didn't see 'hello.' I understand the stuff below, how it uses JS's weird properties to the basic types... but how does it encode characters?
It uses various techniques to get at e.g. type names, and then uses string indexing to access characters in the type name. It has enough characters like this to be able to call fromCharCode.
Re: JSFuck – Write any JavaScript with 6 Characters: []()!+
#18I dont get it :/ if it says: 1 => +!+[] Then why does it still translate to 1128 characters? :/
Re: JSFuck – Write any JavaScript with 6 Characters: []()!+
#19While funny looking, what is the ingenuity behind it?
Many people here on HN never took compsci in school, so strictly speaking it's just a translator - http://en.wikipedia.org/wiki/Translator_(computing) . It's more a showoff of a js idiosyncrasy - they found an ugly looking subset of characters that is Turing complete and wrote a translator to it. If you're new to the concept of Turing tarpits, then this should blow your mind. On the other hand, this is a sufficiently…