Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to cast an object to byte array in javascript

Tags:

javascript

This is my object var loginParameters = ["Tander", "ali", "1", "WINDOWS", "2.0", "TOSHIBA-PC"]

And I want to convert this object to byte array that will look like byte[] objName. But I couldn't find anything about this.

How can I succeed this?

like image 826
Mehmet Ince Avatar asked Oct 21 '25 10:10

Mehmet Ince


1 Answers

var mainbytesArray = [];
for(var i = 0; i < loginParameters.length; i++){
    var bytes = [];
    for (var j = 0; j < loginParameters[i].length; ++j)       
        bytes.push(loginParameters[i].charCodeAt(j));
    mainbytesArray.push(bytes);
}
like image 119
PSR Avatar answered Oct 23 '25 00:10

PSR



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!