TypedArr (TA05)
1: const number = 12345;
2:
3: // 1. Convert to floating-point
4: const floatNumber = parseFloat(number);
5: console.log("Floating-point:", floatNumber); // Output: 12345
6:
7: // 2. Convert to BigInt
8: const bigIntNumber = BigInt(number);
9: console.log("BigInt:", bigIntNumber); // Output: 12345n
10:
11: // 3. Convert to binary
12: const binaryString = number.toString(2);
13: console.log("Binary:", binaryString); // Output: "11000000111001"
14:
15: // 4. Convert to boolean
16: const booleanValue = Boolean(number);
17: console.log("Boolean:", booleanValue); // Output: true
18:
19: // 5. Convert to character string
20: const charString = String.fromCharCode(number);
21: console.log("Character:", charString); // Output: "〹"
22:
23: // 5a. Convert to string (digits as string)
24: const stringValue = number.toString();
25: console.log("String:", stringValue); // Output: "12345"
Conversion Type JavaScript Code Output for 12345 Floating-point (Float) parseFloat(number) 12345 BigInt BigInt(number) 12345n Binary number.toString(2) "11000000111001" Boolean Boolean(number) true Character String String.fromCharCode(number) "〹" (Unicode char) String (Digits) number.toString() "12345" Floating-point: 12345 BigInt: 12345n Binary: 11000000111001 Boolean: true Character: 〹 String: 12345
TypedArr 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
Binary context:
- (2019) How to change image Exif metadata #Binary
- (2018) З'ясування алгоритмів оновлення Documat-CD SEB. #Binary
- (2016) JS6 Typed Array #ES6 #Binary
- (2015) Сховище графіки на SQL FileStream та канал браузеру multipart/form-data. #Sql #WebServiceClient #Binary
- (2012) Робота з байтами у VB.NET - ChrW, BitConverter.ToInt32, Convert.ToInt32, Byte.Parse, ToString("X2") / AllowHexSpecifier, GetBytes/GetString, New Byte(N) {}, UInt32 = &H33 #Binary #NetCommon
- (2005) DumpExe - утилитка дампирования структуры NET-сборок с открытым исходным текстом. #Binary #WinDesktop
- (2003) DVD - формат и обзор техник работы с ним. #Binary
- (2002) PE - формат исполняемого файла. #Binary
- (2002) FRX-парсер - моя утилитка для выкусывания рисунков из шестерочного FRX-файла. #WinDesktop #Vb6 #Binary
Comments (
)

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