id: number;
this.id = +id;
When local id is null then +id results in 0
When local id is undfined then +id results in NaN
The same results I get with Number(id)
instead of the +id
How can I get consistent/same return value for the not successful conversion into a number?
As both
0
,null
,NaN
andundefined
are falsy, you could just set the value to something if it's falsy