Converting Non-numeric values to Numbers
suggest change~~ Could be used on non-numeric values. A numeric expression will be first converted to a number and then performed bitwise NOT operation on it.
If expression cannot be converted to numeric value, it will convert to 0.
true and false bool values are exceptions, where true is presented as numeric value 1 and false as 0
let a = ~~"-2"; // a is now -2
let b = ~~"1"; // b is now -1
let c = ~~"0"; // c is now 0
let d = ~~"true"; // d is now 0
let e = ~~"false"; // e is now 0
let f = ~~true; // f is now 1
let g = ~~false; // g is now 0
let h = ~~""; // h is now 0
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents