What is a more graceful method for checking if a variable is truthy but also passes when it's equal to 0? The current verification
if(var !== undefined && var !== null)
is lengthy and doesn't account for all scenarios such as undefined
or NaN
. Furthermore, I am utilizing TypeScript and have declared it as an optional number.