4 ms·
x += y; x = x + y; x = y; x = x y; x ||= y; x || (x = y); // Why? // Why not x ||= y; x = x || y;? let fee = 123_00; // $123 (12300 cents, apparently) // W
by bungalilac 5y ago
x += y; x = x + y;
x = y; x = x y;
x ||= y; x || (x = y); // Why?
// Why not x ||= y; x = x || y;?
let fee = 123_00; // $123 (12300 cents, apparently) // Why not 12300?
let amount = 123_4500; // 123.45 (4-fixed financial) // Why not 1234500?
// Why not just ignore those underscore and let Indians type like 3_00_00_000
// or Japaneses type like 1234_0000
- Ennea 5y agoRegarding the numerical separators: they're for readability, and readability only. They do not change the numbers in any way. 12300 is the same as 123_00 is the same as 1_2_3_0_0. Up to you entirely.
- tardismechanic 5y agoBecause "x = x || y;" would always perform the assignment due to precedence. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR_assignment#short-circuit_evaluation https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...