MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey

SIMD.js has been taken out of active development in TC39 and removed from Stage 3. It is not being pursued by web browsers for implementation anymore. SIMD operations exposed to the web are under active development within WebAssembly, with operations based on the SIMD.js operations.

The static SIMD.%type%.splat() method creates a new SIMD data type with all lanes set to a given value.

Syntax

SIMD.Float32x4.splat(s)
SIMD.Float64x2.splat(s)

SIMD.Int8x16.splat(s)
SIMD.Int16x8.splat(s)
SIMD.Int32x4.splat(s)

SIMD.Uint8x16.splat(s)
SIMD.Uint16x8.splat(s)
SIMD.Uint32x4.splat(s)

Parameters

s Optional
The value to set all lanes to. This is an integer for int types and a double for float types.

Return value

A new SIMD data type with all lanes set to a given value.

Description

When constructing SIMD data types, multiple arguments for the lane values are expected. The splat function sets a single value for all lanes, allowing you to quickly assemble a new SIMD data type.

If you don't specify a value s, the lanes of int SIMD types will be set to 0, and for float SIMD types the lanes will be set to NaN.

Examples

SIMD.Float32x4.splat(3);
// Float32x4[3,3,3,3]

SIMD.Float64x2.splat(3);
// Float64x2[3,3]

SIMD.Int8x16.splat(3);
// Int8x16[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3]

SIMD.Int16x8.splat(3);
// Int16x8[3,3,3,3,3,3,3,3]

SIMD.Int32x4.splat(3);
// Int32x4[3,3,3,3]

SIMD.Uint8x16.splat(3); 
// Uint8x16[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3] 

SIMD.Uint16x8.splat(3); 
// Uint16x8[3,3,3,3,3,3,3,3] 

SIMD.Uint32x4.splat(3); 
// Uint32x4[3,3,3,3]

Specifications

Specification Status Comment
SIMD
The definition of 'SIMDConstructor.splat' 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: fscholz, eduardoboucas
 Last updated by: fscholz,