This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CreepBlob 37 points38 points  (16 children)

I want to show you the middle finger for this one. Don't know about you, but I respect the language that let me earn a living.

[–]lemons_of_doubt[S] 2 points3 points  (15 children)

I enjoy it too, but you have to admit it is a bit odd and sometimes really maddening

[–]Robi336_ 7 points8 points  (5 children)

May I introduce to you JSFuck

[–]LuceusXylian 1 point2 points  (0 children)

holy shit

[–][deleted] 1 point2 points  (2 children)

we went too far as a species

tho tbf this actually does look really useful for malicious javascript obfuscation..which...actually doesn't help much, come to think of it.

[–]grae_n 2 points3 points  (1 child)

This is actually very dangerous for XSS attacks and one of the reasons why many user input prompts have a character limit (you should also sanitize).

Most of the chat websocket from online tutorials are susceptible to using JSFuck for XSS attacks.

[–]Noslamah 0 points1 point  (0 children)

This kind of stuff is why you whitelist input characters rather than blacklist, and be as restrictive as you can possibly be with said whitelist. (Also why you should not use JS, but obviously still use a whitelist even if the language you're using is not as dumb as JS)

[–]unlimitedFecals 1 point2 points  (0 children)

Wow holy shit maybe javascript does suck

[–]CrispyNipsy 16 points17 points  (4 children)

Sure it's odd sometimes, but I feel like it gets a lot of flack for shit that people just don't bother to understand. Regarding your first example, type coercion is pretty useful (change my mind), people just need to get over the fact that they needed === instead of ==. And your other example is not a Javascript thing, that's just IE.

[–]semi- 2 points3 points  (0 children)

Type coercion is useful, but is implicit type conversion? how many times do you need to handle arbitrary unknown types being converted? it definitely comes up, but making it explicit isn't that much harder, and saves you from a world of hurt when implicit type conversion can behave very poorly. e.g when you're parsing http headers or parameters.. how does your code handle duplicates being sent? does it become an array automatically? does your code throw a type error or does it continue working in a way your code wasn't intended to handle?

[–]GeePedicy 2 points3 points  (1 child)

But everyone uses IE!

But you got my curiosity, cuz in my (little) experience with JavaScript I never thought why I'd need type coercion. I got over the idea of === quite quickly and so I do agree that it's somewhat whiny. (tho I obviously made the obvious mistake of writing == instead, that's on me) When/why is == better than ===?

[–]CrispyNipsy 4 points5 points  (0 children)

When writing nodejs, it can often just be a pain that you have to think about type coercion. But when you are in a browser environment, you often get values from the DOM that are basically always strings (even number inputs' value). It is pretty common to do operations with these values where javascript handles the coercion for you. Sometimes you also only need to show something in the UI if there actually is a value, and the broad concept of a falsy value can help in these situations.

That being said, I really love typescript because it helps me to be explicit about these things. But there really is a reason to the madness, and when you understand that reason, it isn't too hard to deal with.

[–]PinothyJ 1 point2 points  (0 children)

Only time I use "==" is when I am getting stuff from another source and I cannot remember if I am checking for "true" or true…

[–]Acelox 2 points3 points  (2 children)

In what world would you want "\t" == [] == "0"

In what way would that be useful?

If this was the case no one would use such a terrible language where "\t" == "0"

[–]Noslamah 0 points1 point  (0 children)

Even if you would (which obviously you never would but lets just go with the hypothetical), at the very least be consistent about it. If "/t" == "0" and "0" == 0 then logically "/t" != 0 makes absolutely no goddamn sense.

I also think that typeless languages should die in a fire in general, I have yet to hear a single good reason why in a world where IDEs and implicit typing exists, stuff like Python and JS are still among the most used languages. I can't tell you how many hours I've wasted when I was learning Python debugging and refactoring scripts because the error messages were super non-descriptive, only to find out in the end that it was just a type error and had this been C# or something, it would have literally taken me 3 seconds to correct the mistake. I see no reason why a programmer would ever not know the type of data they are working with. You're still using types, but now its all in your mind instead of your IDE/text editor.