JSFiddle - React, Tailwind, and code Playground
by bgrins
JavaScript
var myArray = new ArrayBuffer(100);
window.longInt8View = new Uint8Array(myArray);
for (var i=0; i< longInt8View.length; i++) {
longInt8View[i] = i % 255;
}
document.body.textContent = "Is typed array? " + isTypedArray(longInt8View);
function isTypedArray(obj) {
var typedArrayTypes = {
"[object Int8Array]": 1,
"[object Uint8Array]": 1,
"[object Uint8ClampedArray]": 1,
"[object Int16Array]": 1,
"[object Uint16Array]": 1,
"[object Int32Array]": 1,
"[object Uint32Array]": 1,
"[object Float32Array]": 1,
"[object Float64Array]": 1
};
var type = Object.prototype.toString.call(obj);
return type in typedArrayTypes;
}