Does it matter whether Number or number is used in Typescript / Javascript? For example does number perform better than Number? I'm also assuming that Javascript will be fine with number / Number and vice versa?
The answer in Typescript primitive types: any difference between the types “number” and “Number” (is TSC case-insensitive)? says never use Number
, but does not explain why. In other words it does not say, "If you use Number then this will happen ..." or "If you use Number vs number then typeof
or instanceof
checks outcomes will be different depending on what type is used".
For example if you use const arr = any[]
and then pass a Number
instance as an index to the array Javascript throws an exception. I'm not saying this is the case, just providing an example of the type of answer I'm looking for.
Update
Just came across a specific example from my code:
const errorIndex:Array<Number> = [];
Does it matter whether Array<Number>
or Array<number>
is used?