How to check if javascript based arrays are supported?

Want to check with javascript if your browser supports a typed array http://caniuse.com/#feat=typedarrays

I tried this, but it doesn't seem to be very good, because some browsers have only partial support ..:

if(window.ArrayBuffer){alert('typed array supported')} 
+6
source share
1 answer

It seems that some browsers (IE10) do not support Uint8ClampedArray , and if this is the function you are going to use, you can just check it

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

If the check returns false, arrays with arrays and / or are not supported.
If you do not need Uint8ClampedArray , you can stick with what you have, personally I like to use in

 if ( 'ArrayBuffer' in window ) { ... 
+8
source

Source: https://habr.com/ru/post/978949/


All Articles