Coersion (CR23)
1: const num = 42;
2: const str = String(num); // Number to string
3: const bool = true;
4: const strBool = String(bool); // Boolean to string
5: console.log(strBool)
6: const big = 1234567890123456789n;
7: const strBig = String(big); // BigInt to string
8: console.log(strBig)
9: const nul = null;
10: const strNul = String(nul); // Null to string
11: console.log(strNul)
12: const und = undefined;
13: const strUnd = String(und); // Undefined to string
14: console.log(strUnd);
15: const special = NaN;
16: const strSpecial = String(special); // NaN to string.
17: console.log(strSpecial); // "NaN"
String Conversions: true 1234567890123456789 null undefined NaN
Coersion context:
ES6 context:
- (2024) Notes about JS Closures. #ES6
- (2024) Notes about Javascript asynchronous programming. #ES6
- (2022) Modern Javascript books #ES6 #Doc
- (2021) JS learning start point #ES6
- (2021) Maximilian Schwarzmüller Javascript lecture #ES6
- (2021) Javascript interview question from Happy Rawat #ES6
- (2021) Javascript tests #ES6
- (2016) New unique features of Javascript (updated). #ES6
Comments (
)

Link to this page:
http://www.vb-net.com/JavascriptES6/CR23.htm
|