If a variable called foo
is set to null in JavaScript, the output of typeof(foo)
will be displayed as object
.
Contrary to JavaScript, in Typescript, even if foo
was initially declared as a number
, setting foo=null
would result in typeof(foo)
being recognized as an object
rather than a number
.
When working with Typescript or JavaScript, is there any method available to identify whether a variable is of type number
, regardless of it being temporarily assigned the value of null
?