Nodejs WTF
-
Here's a bit of Friday entertainment for you all. I saw this on StackOverflow and thought I'd share for your amusement :-)
TLDR: REPL insets implicit parentheses around each statement so the following:
hi)(
becomes:
(hi)()
and therefore compiles and runs!
You can even pass arguments to a mangled function call like so:
hi)(args
and this becomes:
(hi)(args)
and compiles and runs correctly.
I'll have to remember this one for the next bring your own code competition. :-) I think this feature has got a lot of potential for evil code and WTF-ery.
Eric Lippert made me laugh in the comments with <quote>And I thought automatic semicolon insertion was bad.</quote>
-
Somebody at some point in their life, hopefully not on an LSD trip, thought this was a good idea? I don't want to live on this planet anymore.
-
Now if browsers were to support js completion/insertion for:
() {} ;
it would allow programmers to focus on the important parts (i.e. the beginning) and let the machine deal with the details. People spend way too much time checking for those closing symbols while they should think about Features.
var p = $.post('/submit', function confirmSubmit( .done(function( { $('#Message.text('Thank you .fail(function(xhr, err alert($(xhr.responseText
I think I will send that suggestion to the Firefox team. How hard can it be, browsers already do that for html tags!
-
@Ronald said:
I think I will send that suggestion to the Firefox team.
Make sure to tell them to update their credits list!
-
@Ronald said:
Now if browsers were to support js completion/insertion for:
() {} ; ' "
it would allow programmers to focus on the important parts (i.e. the beginning) and let the machine deal with the details. People spend way too much time checking for those closing symbols while they should think about Features.
var p = $.post('/submit, function confirmSubmit( .done(function( { $('#Message.text('Thank you .fail(function(xhr, err alert($(xhr.responseText
I think I will send that suggestion to the Firefox team. How hard can it be, browsers already do that for html tags!
-
They should insert
function
. That would be the real time saver.And then why stop there? Make them insert
return
andfor
too. In the case offor
, the declaration of the iteration variable should be optional too.As for
while
andif
, I'm sure they can find a way of determining which was meant when a boolean expression is seen, also for when you omit the initialization and afterthought in afor
loop.
-
@Zecc said:
Keep up with that kind of silliness and you end up at CoffeeScript.They should insert
function
. That would be the real time saver.And then why stop there? Make them insert
return
andfor
too. In the case offor
, the declaration of the iteration variable should be optional too.As for
while
andif
, I'm sure they can find a way of determining which was meant when a boolean expression is seen, also for when you omit the initialization and afterthought in afor
loop.
-
@anonymous234 said:
@Ronald said:
I think I will send that suggestion to the Firefox team.
Make sure to tell them to update their credits list!They're probably already using Excel for it anyway.