While writing tests for a value formatter service I noticed that there is something odd about Number.prototype.toLocaleString("sv-SE")
.
let myValue = (100000).toLocaleString("sv-SE");
console.log(typeof myValue);
console.log(myValue);
console.log(myValue === "100 000"); // false, why?
I expect the last log statement to return true
. But it does not, why?
As mentioned in my comment, the "space character" is actually U+00A0 (NO-BREAK SPACE). This character looks exactly like a normal space but isn't applicable for end-of-line word-wrap algorithms.
The following code works as expected:
let myValue = (100000).toLocaleString("sv-SE");
console.log(typeof myValue);
console.log(myValue);
console.log(myValue === "100\u00a0000");