I think the dev missed a nullcheck before `handlebars.compile(name)`, don't you think?

// this snippet is from our product's repo ;)

  • 1
    For the Lord, delete that if block... Or is it the notorious JS?
  • 1
    If it is null return it and if it is not null return it.

    If you are at a red light drive forward, if you are not at a red light drive forward.

    If you are suicidal, kill yourself, if you are not suicidal, kill yourself.
  • 0
    I thought handlebars was long dead
  • 2
    @AlgoRythm You'd be surprised what kind of magic you can find in this repo :)
  • 0
    @HitWRight Why would it be different in JS?
  • 0
    @theuser I remember hearing about == and === operators being different. So for example if null == 0 and null =/= 0 if different operators are used, it could be written as a shorthand catch multiple invalid states.
  • 1
    @HitWRight Yes, they use the same comparison algorithm, but the triple equals will not convert falsey and truthy values before comparing.

    If you do "undefined == null" it will return true because both values are coerced to false (they are falsey).

    "Boolean(undefined) === Boolean(null)" will return true because you are doing a manual explicit conversion beforehand.
Add Comment