If variable value consists only of digits 0-9 then it is a decimal number;
If variable value consists only of digits 0-9 or letters A-F then it is a hex number;
Otherwise it is a string.
let variable = 3984566; // variable = 3984566
let variable = 48DC45F; // variable = 76399711
let variable = 48dc45f; // variable = 76399711
let variable = 48dC45f; // variable = 76399711
let variable = 45TXEE45; // variable = "45TXEE45"
If a variable only consists of letters then it is a reference.
const ff = true:
const a = ff:
1 Like
Ambiguous syntaxes are an incredibly bad idea. This would only ever allow you to omit the prefix on a small subset of hex numbers - those that start with a decimal digit, and contain an A-F digit as well. (If it starts with a-f, it's a variable name, even if it contains decimal digits after that.)
1 Like
Almost every language I've seen wants to move away from that kind of implicit representation. It's extremely bug-prone, because you don't immediately know the type of something just from looking at it.