Elektrine lite

← Feed

@NateNate60@lemmy.world

2026-11-02 07:51 UTC

This diagram is nonsense. JavaScript programmers know to simply never use == but to use === instead. Half of JavaScript is like this. Oh, there’s a feature, but it behaves in a super weird way so we don’t use it to avoid the weirdness.

Replies (6)

  • @dan@upvote.au 2026-11-02 09:05

    The recommended ESLint rules catch most of the bad stuff, and these days this is all you need in your ESLint config to enable them: import {defineConfig} from 'eslint/config'; import js from '@eslint/js' export default defineConfig([ js.configs.recommended, ]; There’s one use case where == is still commonly used: == null matches both null and undefined. Lint rules that block == usually allows the null case as an exception.

    Open ##5467091

  • @9point6@lemmy.world 2026-11-02 09:08

    IIRC modern linter rulesets generally just outright error if you do anything remotely like this.

    Open ##5467096

  • @GeirGrusom@lemmy.world 2026-11-02 09:40

    Where’s the >== operator? Because they also have the exact same problem.

    Open ##5467159

  • @ParlimentOfDoom@piefed.zip 2026-11-02 14:42

    As someone trying to learn Javascript, it just makes me mad that at this garbage heap of a language is so widely used.

    Open ##5468092

  • When I had to use JS I wrote JS 1.2 because why not. Fun how I had strings of numbers instead of actual numbers in some for loops, yet it all sort of functioned until something didn’t. I then decided to add Number() to random values just in case.

    Open ##5468447

  • @nykula@piefed.social 2026-11-02 21:37

    == has never, ever caused me a single issue. Parsing all server input with type-safe schemas makes sure that where I expect a string, I get a string; where I expect a number, I get a number. Bad data must result in an error before it reaches logic.

    Open ##5469871