MDN’s new design is in Beta! A sneak peek:

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 method creates a new integer SIMD data type with the lane values being a selection match from a selector mask.

Syntax, trueValue, falseValue), trueValue, falseValue), trueValue, falseValue), trueValue, falseValue), trueValue, falseValue), trueValue, falseValue), trueValue, falseValue), trueValue, falseValue)


An int32x4, int16x8 or int8x16 that is used as the selector mask.
If the selector mask lane is true, pick the corresponding lane value from here.
If the selector mask lane is false, pick the corresponding lane value from here.

Return value

A new SIMD data type.


The method selects lanes from a selection mask. Masking (or "branching") lanes is useful as you can't operate on a fraction of data in SIMD data types. However, with masks and the select function, you can branch and merge vectors to assemble the result vector you need.


Custom selection mask

This example uses the SIMD.Bool32x4 type to create a custom selection mask. With this mask, you are able to select the first and the last lane from the first Float32x4 data type. Thus, the select function selects the first and last lane from vector a and the second and third lane from vector b (or the sum vector in the second select).

var a = SIMD.Float32x4(1, 2, 3, 4);
var b = SIMD.Float32x4(5, 6, 7, 8);

var mask = SIMD.Bool32x4(true, false, false, true);, a, b);
// Float32x4[1, 6, 7, 4]

var sum = SIMD.Float32x4.add(a, b);, a, sum);
// Float32x4[1, 8, 10, 4]

Operations returning a selection mask

All SIMD comparison operations return a selection mask from which you have to select to actually get the result of the comparison:

var a = SIMD.Float32x4(0, 12, 3, 4);
var b = SIMD.Float32x4(0, 6, 7, 50);

var mask = SIMD.Float32x4.lessThan(a, b);
// Bool32x4[false, false, true, true]

var result =, a, b);
// Float32x4[0, 6, 3, 4]


Specification Status Comment
The definition of '' 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

Document Tags and Contributors

 Contributors to this page: nmve, eduardoboucas, fscholz
 Last updated by: nmve,