4
Awlex
191d

Damn I hate js in the browser. I fixed a bug, but I don't understand what caused it or how my fix works.

I have 2 semantically identical elements that do the same thing, one of them crashes, while the other doesn't. Screw it!

Comments
  • 2
    Wonderful world of JS. Where a string can be a number and nobody knows when or how.
  • 1
    @ostream Yeah, but that does not solve the problems.

    !!['test']

    true

    ['test'] == true

    false

    !!null; // -> false

    null == false; // -> false

    typeof []; // -> 'object'

    typeof null; // -> 'object'

    // however

    null instanceof Object; // false

    (There is a whole git with these cases : https://github.com/denysdovhan/...)

    I prefer to stick with strongly typed variables and not have to check every time if the type changed somehow in the process.
  • 0
    It's definitely an object mutated somewhere
Add Comment