How to use Array.map() on a string to get an array of bytes in ASCII representing the string characters in JavaScript

1 Answer

0 votes
var map = Array.prototype.map;
var arr = map.call('PHP Developer', function(x) { return x.charCodeAt(0); });

console.log(arr); 


/*
run:  
 
 [80, 72, 80, 32, 68, 101, 118, 101, 108, 111, 112, 101, 114]
  
*/

 



answered May 21, 2016 by avibootz
...