W3cubDocs

/JavaScript

SIMD.check

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

The static SIMD.%type%.check() method returns a SIMD data type if the parameter is a valid SIMD data type and the same as %type%. Otherwise, a TypeError is thrown.

Syntax

SIMD.Float32x4.check(value)
SIMD.Float64x2.check(value)

SIMD.Int8x16.check(value)
SIMD.Int16x8.check(value)
SIMD.Int32x4.check(value)

SIMD.Uint8x16.check(value)
SIMD.Uint16x8.check(value)
SIMD.Uint32x4.check(value)

SIMD.Bool8x16.check(value) 
SIMD.Bool16x8.check(value) 
SIMD.Bool32x4.check(value)
SIMD.Bool64x2.check(value)

Parameters

value
The value to check whether it is a corresponding SIMD data type.

Return value

The corresponding SIMD data type, if valid.

Exceptions

A TypeError, if the argument is not a valid SIMD data type or does not correspond to %type%.

Examples

Checking if a SIMD data type is valid

var a = SIMD.Float32x4(1, 2, 3, 9);

SIMD.Float32x4.check(a);
// Float32x4[1, 2, 3, 9]

SIMD.Float32x4.check([1,2,3,4]);
// TypeError

SIMD.Int32x4.check(a);
// TypeError as a is a Float32x4 not an Int32x4

SIMD.Int32x4.check({});
// TypeError
SIMD.Int32x4.check('Hi Vector-Viktor!');
// TypeError

Specifications

Specification Status Comment
SIMD
The definition of 'SIMDConstructor.check' in that specification.
Draft Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support No support Nightly build No support No support No support
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support No support No support Nightly build No support No support No support

See also

© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SIMD/check