JPDev@programming.dev to Programmer Humor@programming.dev · 1 year ago===programming.devimagemessage-square61fedilinkarrow-up1627
arrow-up1610image===programming.devJPDev@programming.dev to Programmer Humor@programming.dev · 1 year agomessage-square61fedilink
minus-squareschnurrito@discuss.tchncs.delinkfedilinkarrow-up16·1 year agoby not ever using == and !=, but only === and !==
minus-squareblackn1ght@feddit.uklinkfedilinkarrow-up10·1 year 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·1 year 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·1 year agoYep. It’s the only reason I’m still somewhat sane.
minus-squarefidodo@lemmy.worldlinkfedilinkEnglisharrow-up2·1 year 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·1 year 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·1 year agoAnd typescript is basically just a linter on steroids
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