JavaScript: Non-standard ways to convert characters to codes, or strings to binary arrays (arrays of numbers) -


Is there any tricks in JavaScript that change the child's code except for .charCodeAt (i)? I want to convert the string to binary array in the fastest way (like faster than charcotte). But I'm also interested in learning about slow methods.

You can do a lookup table, but I doubt it will be any faster. Something like this:

  function (str) {var code = {}, output = []; (Var i = 0; i & lt; 256; i ++) {string code [fromCharCode (i)] = i; } (Var i = 0; i & lt; str.length; i ++) {output.push (code [str [i]]); } Return output; }   

Generally speaking that if you can go with the original code, then go with the original code.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -