Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if javascript typed arrays are supported?

Would like to test with javascript if browser support typed array http://caniuse.com/#feat=typedarrays

i tryed this but seems not the good way because some browser have just a partial support..:

if(window.ArrayBuffer){alert('typed array supported')}
like image 654
flaubert Avatar asked Dec 01 '14 15:12

flaubert


Video Answer


1 Answers

It seems some browsers (IE10) doesn't support Uint8ClampedArray, and if that is a feature you intend to use, you can just check for it

if ( 'Uint8ClampedArray' in window ) { ...

If the check returns false, typed arrays and/or clamped arrays are not supported.
If you don't need Uint8ClampedArray, you can stick with what you've got, personally I like to use in

if ( 'ArrayBuffer' in window ) { ...
like image 60
adeneo Avatar answered Oct 10 '22 13:10

adeneo