Ghost Posted June 27, 2020 Report Share Posted June 27, 2020 How to easily swap or change endianness in Javascript, NodeJS, etc. with one simple function! changeEndianness() const changeEndianness = (string) => { const result = []; let len = string.length - 2; while (len >= 0) { result.push(string.substr(len, 2)); len -= 2; } return result.join(''); } You can then use this function with any string to convert its endianness Example of using function: var yourstringvar = 'Your string goes here to swap endianness'; var newendian = changeEndianness(yourstringvar); console.log('Your newly swapped endian string', newendian); 1 Quote Founder of BlockForums.org - PM me for any help - Join our Discord Server: https://discord.gg/UPpQy3n Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.