How to check if javascript typed arrays are supported?

1k views Asked by At

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')}
1

There are 1 answers

0
adeneo On BEST ANSWER

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 ) { ...