TypedArr (TB01)
1: const buffer = new ArrayBuffer(4); // 4 bytes for a 32-bit integer
2: const view = new DataView(buffer);
3:
4: // Write a 32-bit integer in little-endian format
5: view.setInt32(0, 12345, true); // true for little-endian
6:
7: // Read the 32-bit integer in little-endian format
8: const littleEndianValue = view.getInt32(0, true);
9: console.log(littleEndianValue); // Output: 12345
10:
11: // Read the 32-bit integer in big-endian format
12: const bigEndianValue = view.getInt32(0, false);
13: console.log(bigEndianValue); // Output: 875770417 (different due to endianness)
Key Concepts of DataView: ArrayBuffer: A fixed-length raw binary data buffer. It doesn’t directly allow you to manipulate its data; you need a DataView or typed array to access it. DataView: Provides a view into an ArrayBuffer to read/write multi-byte data types. Allows you to specify endianness (little-endian or big-endian) for each operation. Endianness: Little-endian: The least significant byte (LSB) is stored at the lowest memory address. Big-endian: The most significant byte (MSB) is stored at the lowest memory address. Common Methods: setInt8, setUint8, setInt16, setUint16, setInt32, setUint32, setFloat32, setFloat64 getInt8, getUint8, getInt16, getUint16, getInt32, getUint32, getFloat32, getFloat64 Writing and Reading a 32-bit Integer 12345 959447040
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/TB01.htm
|