Wat
91–100 of 103 posts
Re: Wat
#92Re: Wat
#93I guess you had to be there. I can see why someone might find this funny, but honestly, nothing is that funny. Some behavior in Javascript is surprising, but not that surprising.
If you've ever gone through a phase (or a graduate degree!) of thinking deeply about programming language design, you might, as I do, find Javascript's expression evaluation behavior to be just about the funniest thing around.
Re: Wat
#94that weird behavior of javascript can actually be used for xss attacks, by being able to assemble strings. for example: (![]+[])[+!+[]] produces an "a". https://news.ycombinator.com/item?id=1153383
Re: Wat
#95Guess I'm not a hacker? It's like watching a rerun I've seen twice over with the laugh track turned up to 11 (just to clarify, someone said it was a repost but I haven't seen it before).
I didn't laugh because I was so worried that if I didn't laugh I wouldn't be considered a hacker :(
Re: Wat
#96Re: Wat
#97Earlier quoted context omitted.
I understand the downvotes since this is HN and you people don't like useless comments here. But I simply thought it was very funny. No need to be mean here.
For the record, the downvotes aren't to be mean. We just don't want this turning into a Reddit clone and/or fill the comments with run-of-the-mill comments you'd see on any PHPbb forum. No, I wasn't one of the ones who downvoted you and no, I'm not trying to be mean. There used to be times I wondered why an innocent comment of mine was downvoted and thought I'd just let you know instead of leave you hanging.
Re: Wat
#98How does this have anything to do with a sense of humor specific to hackers? Don't all professionals enjoy jokes about their field?
But maybe it is just because I write code for a living...
Re: Wat
#99What's the "correct" ("less funny"?) result of Array(16).join("wat" - 1) + " Batman!" ? Empty strings separated with NaN s look perfectly logical to me (I'm a JS guy though, so, well, bear with me).
The first thing it should do is TypeError that null is not a string. Or don't join null fields because there is nothing there.
If is does convert null to '', then it should TypeError on string - int. If it is not going to TypeError it should do something sensible, like slice the string
> Array(16).join("wat".slice(0,-1)) + " Batman!"
'wawawawawawawawawawawawawawawa Batman!'
I think the correct thing would be to TypeError in two different places. Or change the language so things that don't error actually work. Returning a string with NaNs in it will just lead to uncaught errors. If it actually returns something it should probably be ' Batman!'.JavaScript nuttiness:
Now it's zero:
> null + 1
1
Now it's "null": > null + "text"
'nulltext'
Now it's a blank string: > [null, null, null].join()
',,'
Python errors when things don't make sense, and forces you to make them make sense:If it doesn't work, error:
>>> "wat" - 1
Traceback (most recent call last):
File "", line 1, in
TypeError: unsupported operand type(s) for -: 'str' and 'int'
Can't join None into a string: >>> ','.join([None, None, None])
Traceback (most recent call last):
File "", line 1, in
TypeError: sequence item 0: expected string, NoneType found
Convert None to a string if you want: >>> ','.join([str(i) for i in [None, None, None]])
'None,None,None'
But it makes more sense to drop the None: >>> ','.join([str(i) for i in [None, None, None] if i])
''Re: Wat
#100Earlier quoted context omitted.
It's jsc (comes with Webkit) - it's present on Mac OS X by default in /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc You can just do: sudo ln /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc /bin/jsc To be able to invoke it directly from the command line.
That is extremely useful. Do you know if any testing libraries or other useful functionality have been built around this? I suppose if you are a WebKit-only developer, this utility could have many useful applications.