It looks like it's JavaScript meant to run in a browser. Instead of doing traditional error handling, the code snippet automatically searches Stack Overflow for any error that the program throws while running, so you don't have to do it yourself.
You can kind of break it: JS allows you to throw anything, including things that don't have a .message property. E.g. throw 42 will end up searching stackoverflow for "[js] undefined".
Rule[2] violation - reposted over and over, will be added to common posts.
Rule[2]: All posts that have been on the first 2 pages of trending posts within the last month, is part of the top of all time, or is part of common posts is considered repost and will be removed on sight.
If you feel that it has been removed in error, please message us so that we may review it.
I was thinking about this (and my downvoted) and I use js all the time. I think between webpack, Babel, and all of the linters it almost doesn’t matter. I mean if I ran this within my react or vuejs stacks the page wouldn’t even show up even if it didn’t run this code.
87
u/[deleted] Nov 06 '18
Hahaha pure genius.
58
u/Lightfire228 Nov 07 '18
This is going down in history
120
u/readboywhocriedwolf Nov 06 '18
Wow this is actually a really good idea.
28
u/Jaymageck Nov 07 '18
Except when you accidentally roll this into production and users wonder why they're being redirected.
49
u/blipman17 Nov 06 '18
I'm horrified and amazed at thesame time.
20
u/ImmaDebugYou Nov 07 '18
Brilliant! I'm going to implement this in real project!
7
u/[deleted] Nov 06 '18
That's amazing
5
u/Advntur78 Nov 07 '18
This is awesome
4
u/shrys Nov 07 '18
I think its safe to enclose it with encodeComponentUri
4
u/NiciusB Nov 07 '18
It's not a good idea to actually use it, but I wrote it so you don't have to:
10
u/Zbox01 Nov 06 '18
Can someone explain this to me please?
3
u/matveyKievUa Nov 07 '18
Reddit is a good place to witness the cycle of repost in nature.
2
u/ijusthatellamas Nov 07 '18
Oh my god !
2
u/gandalfx Nov 07 '18
You can kind of break it: JS allows you to throw anything, including things that don't have a
.messageproperty. E.g.throw 42will end up searching stackoverflow for "[js] undefined".2
u/bunsslim Nov 07 '18
you shouldve used a template literal
2
u/SkewRadial Nov 07 '18
How abt doing a regex for the answer and eval() the response ? AI level programming lol!
2
u/Mr-0bvious Nov 07 '18
Big, if true
2
u/RohnekKdosi Nov 07 '18
Shouldn't that something be changed to //something to prevent syntax error?
•
u/PatrikxPatrola Nov 07 '18
Your submission has been removed.
Rule[2] violation - reposted over and over, will be added to common posts.
Rule[2]: All posts that have been on the first 2 pages of trending posts within the last month, is part of the top of all time, or is part of common posts is considered repost and will be removed on sight.
If you feel that it has been removed in error, please message us so that we may review it.
1
u/fabrikated Nov 07 '18
😴
1
u/mlabu01 Nov 07 '18
I saw third party libraries throwing exceptions with links to stack overflow, proto-buf .net for example...
-16
u/itshorriblebeer Nov 06 '18
At least make sure your code compiles.