JPDev@programming.dev to Programmer Humor@programming.dev · 10 months ago===programming.devimagemessage-square61fedilinkarrow-up1626
arrow-up1609image===programming.devJPDev@programming.dev to Programmer Humor@programming.dev · 10 months agomessage-square61fedilink
minus-squareButtons@programming.devlinkfedilinkEnglisharrow-up66arrow-down1·edit-210 months agohttps://programming.dev/post/7789832
minus-squareschnurrito@discuss.tchncs.delinkfedilinkarrow-up16·10 months agoby not ever using == and !=, but only === and !==
minus-squareblackn1ght@feddit.uklinkfedilinkarrow-up10·10 months agoBecause in reality you’re not doing stupid stuff like that in the image. And using Typescript definitely helps. However I’m always annoyed that the month parameter when constructing a date object is 0 based. So 1st of Jan is new Date(2024, 0, 1)
minus-squareJaddedFauceet@lemmy.worldlinkfedilinkarrow-up1·10 months agoLooks confusing at first, but I found it nice for accessing a month array. const months = ["Jan", "Feb", ...]; months[0] === "Jan"; const label = months[date.getMonth()];
minus-squareByteJunk@lemmy.worldlinkfedilinkarrow-up3·10 months agoYep. It’s the only reason I’m still somewhat sane.
minus-squarefidodo@lemmy.worldlinkfedilinkEnglisharrow-up2·10 months agoI got by without it for years, but not that I have it I have no idea how I did it back then.
minus-squareJaddedFauceet@lemmy.worldlinkfedilinkarrow-up7·10 months agoBy banishing the bad part of the language with linter. For instance, standard eslint preset has rules that enforce usage of ===, https://eslint.org/docs/latest/rules/eqeqeq These rules often come with project starter template
minus-squarefidodo@lemmy.worldlinkfedilinkEnglisharrow-up4·10 months agoAnd typescript is basically just a linter on steroids
https://programming.dev/post/7789832
deleted by creator
by not ever using == and !=, but only === and !==
Because in reality you’re not doing stupid stuff like that in the image. And using Typescript definitely helps.
However I’m always annoyed that the month parameter when constructing a date object is 0 based. So 1st of Jan is
deleted by creator
Looks confusing at first, but I found it nice for accessing a month array.
const months = ["Jan", "Feb", ...]; months[0] === "Jan"; const label = months[date.getMonth()];
Typescript :)
Yep. It’s the only reason I’m still somewhat sane.
I got by without it for years, but not that I have it I have no idea how I did it back then.
By banishing the bad part of the language with linter.
For instance, standard eslint preset has rules that enforce usage of
===
, https://eslint.org/docs/latest/rules/eqeqeqThese rules often come with project starter template
And typescript is basically just a linter on steroids
Ikr? English is hard /s