Node.js os.endianness() Method
Endianness refers to the order of bits in a sequence within a binary representation of a number.
The os.endianness() method is an inbuilt application programming interface of the os module which is used to get endianness of the CPU of the computer for which the node.js is compiled.
Parameters: This method does not accept any parameters.
Return Value: This method returns a string value that specifies the endianness of the CPU. The returned string will be either
BE (for big endian) or
LE (for little endian).
- LE: It is the most significant bits/values in the sequence that is stored in higher memory address.
- BE: It is the most significant bits/values in the sequence that is stored in lower memory address.
Below examples illustrate the use of os.endianness() method in Node.js:
CPU is little endian format
Note: The above program will compile and run by using the
node index.js command.