I wasted 3 hours on your this. self. null, undefined, + asynch functions, bullshit "features"...


and your taking 8 seconds to compile and test each wild guess that I make until I finally console.log every single fucking variable in order to make sense of it all

so, as usual, FUCK YOU

  • 3
    Use TypeScript with NoImplicitAny.
  • 1
    @makmm ok, I promise
  • 0
    I don't like JS but one thing that helped be learn it faster was using a browser console and checking type/etc using that.
  • 0
    Write better code :D
  • 1
    @D--M do you tell people who complain about writing code in assembly/C this?

    You can always write better code, but some languages are more modern/better to work with for everyday use. JS is definitely dated and shitty to work with, as are most dynamically typed languages.
  • 1

    I'm still a bit new to modern javascript/frontend, only a few years experience

    seems to me javascript has a lot of gotchas

    sure, if I became an expert at js, I could see how to maybe exploit all these funny ways it handles datatypes and scopes

    but I just don't get the use of, for example, 5 different ways to say "false" or null.. it just makes things a huge headache sometimes

    none of it is intuitively obvious, it's quirky and, very much feels to me like "features" and not "bugs" if you get my drift

    but whatever, in a way you're right, a language is a language and a good coder masters it eventually
  • 2
    @rant1ng like:

    0 == " "

    is true

    0 == ""

    is true

    " " == ""

    is false
  • 0

    I mean, I guess with javascript, you have got to REALLY control what values your variables may end up having.

    of course, that's so easy to do in a web environment where connections fail, each client has a choice of like 8 browsers and 50 different version of said browsers over the past decade, etc.

    so yeah, you really gotta be a genius I guess

    cuz that's what we all should be doing

    keeping strict control on our javascript variable datatypes.....AND scopes, manually, in our heads, because we always know what will happen in these environments.

    or, just do this:

    let $varr = whatever;

    self = this;

    somefunction () {

    if($this.varr == null || $this.varr === null && $this.varr !== undefined && $this.varr !== '')

    return $some.headaches;


    *wipes hands*

    problem solved. first try, too.
  • 0
    Yes, of course. C is one of the worst offenders of badly written code.


    Actually, just

    If(obj && obj.var) is good enough in 99% of cases.


    In this thread, people with approximately, fuck all, js experience give their expert opinions. LUL
  • 1
    @D--M oh please, wise master, impart your wisdom.
    Why is JS so great?
  • 1
    Just use Elm. Problem solved
  • 0

    I'm reading about it... seems interesting

    maybe a little overkill for my current needs, but i'll keep it in mind, thanks
  • 0
    Why? What for? You seem to be pretty convinced.
  • 2
    always compare with === (yes, three of them :D), == converts the type

    "" is considered a falsy, 0 is falsy, so 0 == "" is true (type in the console !!"" and !!0 to reflect boolean value)

    but "" === 0 returns false, as they're not the same type.

    " " !== "" as it isn't the same string

    I think that knowing all this in the end helps a lot in writing elegant code or making it stronger when you need it

    Or you could always convert to boolean using !!, not sure about perf in the long run
  • 1
    @Phlisg thanks for the clarification, but my point was also centered around the implicit type coercion not just that operation. When I'm forced to write JS (at work), I do use === for the reasons you specified.

    But thanks for taking the time!
  • 0
    @D--M because you can change my mind with evidence. My mind is made up because the evidence points clearly towards JS being primitive and crappy to work with, but if I'm missing something I'd obviously change my opinion.
  • 1
Add Comment