Skip to content

Instantly share code, notes, and snippets.

@kinjouj
Created June 1, 2012 11:56
Show Gist options
  • Save kinjouj/2851572 to your computer and use it in GitHub Desktop.
Save kinjouj/2851572 to your computer and use it in GitHub Desktop.
JavaScript typed array study demo1
(function() {
"use strict";
var text = 'abcdef';
var text_len = text.length;
var ar = new Array(text_len);
for (var i = 0;i < text_len;i++) {
ar[i] = text.charCodeAt(i);
}
var buf = new Uint32Array(ar);
var buf_len = buf.byteLength;
console.log(buf);
console.log("buf_len: " + buf_len);
var a = '';
for (var i = 0;i < buf_len;i++) {
a += String.fromCharCode(buf[i]);
}
console.log(a);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment