• EuphoricPenguin
    link
    fedilink
    English
    011 months ago

    JS is one of the most fun programming languages ever created; how dare you slander its great name.

      • EuphoricPenguin
        link
        fedilink
        English
        0
        edit-2
        11 months ago

        If I remember correctly, 0 and 1 are considered falsy and truthy respectively, so it should be falsy and truthy and false which I believe would return false.

        Tried it out to double-check, and the type of the first in the sequence is what ultimately is returned. It would still function the same way if you used it in a conditional, due to truthy/falsy values.

        • @kameecoding@lemmy.world
          link
          fedilink
          English
          1
          edit-2
          11 months ago

          yes, that is a solid logic, one that I also applied and expected to be the result.

          that is until a Vue component started complaining that I am passing in a number for a prop that expects a boolean.

          turns out the result of that code is actually: 0, because javascript

          of course if you flip it and try

          false && 0 && 1

          then you get false, because that’s what you really want in a language, where && behaves differently depending on what is on what side.