200
japzio
6y

why so much hate towards javascript? :-D

Comments
  • 18
    Are you saying that you would rather nuke any of the other options?
  • 8
    It's cause there are people whodon't understand Js concepts and can't get their head around JavaScript so they hate on it
  • 3
    @IcyTv Well, it does have some... Ahem, unique concepts though.

    1 == "1" vs 1 === "1" is weird until you understand why it is necessary here.
  • 3
    @ilPinguino this isn't a uniqueue concept tho
  • 0
    @inaba Sorry, I didn't know other languages are doing that - or at least, I never needed another language to do that. I can understand it in JS (Form Input might come as all sorts of things depending on the browser), but I could not see a use in any other context than that...
  • 4
    @ilPinguino quite many weakly typed languages do that, '1' == 1 is expected, less expected is things like [+!+[]]+[+[]] === 10
  • 1
    @ItsNotMyFault I don't mean 1 == "1", I mean the === operator - the "be strict this one comparison" thing is something I never seen in another language.

    As for your [+!+[]]+[+[]] example...

    Why would anyone actually DO that???
  • 3
    Not hate. More like a love-hate relationship
  • 3
    @ilPinguino Works in PHP also
  • 1
    @thremedy I did some PHP a while ago, but I don't really remember doing that... Looks like I was not in deep enough...?
  • 2
    @ilPinguino cause we need a way to compare integers while making sure they're actually integers...

    Also java? == sometimes compares memory addresses while sometimes comparing the value. The equivalent to === would be . equals()...
  • 1
    @ilPinguino also in Elixir and many of the newer dyanmically typed langs; it makes sense to have it too since that corresponds to the triple bar equals sign in math
  • 2
    @woodworks Elixir is one of the many languages I never had contact with. I moved from Basic via some C-likes (C++, C#.net) over to PHP, Perl, Python and later, Ruby on Rails... I'd not consider myself more than "dabbling" in anything but RoR, Python and PHP. Also, I always was a serverside/backend guy - some JS, very litte CSS.

    I only recently(2ish years ago) got back into C++ because I tinker with IoT devices.
  • 1
    @ilPinguino

    Q: "Why would anyone actually do that" ?

    A: Because they can !
  • 0
    @senzory only with a good framework, otherwise Python is a much better starting point. JavaScript is a CODING language, so people who write JavaScript CODE...
  • 2
    @senzory I would say the opposite, people who can't code should not use flexible, forgiving languages like javascript, it is far too easy to create horrible things with it.
  • 0
    @ilPinguino I've been in similar stacks as well :) but I've got a ton of free time on my hands so I'm always looking to get proficient in new langs; I personally absolutely hate Haskell and most functional languages but Elixir doesn't shove it down your throat and is pretty elegant. IMO definitely the best functional lang
  • 0
    JS concepts... Undefined, NaN or null ? Can someone explain when which one will be returned ?
  • 2
    @rim01 When you try to access a value that doesn't exist, you will get undefined. So when you declare a variable without a value and try to get the value of it, it's not defined.

    When you need to know that something is an empty object, like if you have optional parameters, or you get something from a database that is null, or stuff like that.

    And NaN is what you get when your dumb ass tries to do maths on things that aren't numbers (or aren't silently converted to numbers).

    1/"a"
    1/"1a"
    1/{}
    1/[1,2]

    and so on will give you NaN because, they're not numbers. These however, will not

    1/"1"
    1/[]
    1/[1]

    because they're silently converted. Then there's also the good old string concatenation:

    1 + {} == '1[object Object]'

    Will give you true. Now all of these are quite easily fixed by following one simple rule:

    Maths is for numbers.
Add Comment