Javascript Float32Array of()

Introduction

The Float32Array.of() method creates a new typed array from a variable number of arguments.

This method works the same as Array.of().

Float32Array.of(element0[, element1[, ...[, elementN]]])
Parameter Optional Meaning
elementN RequiredElements of which to create the typed array.
let a = Float32Array.of(1);            // Float32Array [ 1 ]
console.log(a);//from  w  w w  .  ja v a2  s .  co m
a = Float32Array.of('1', '2', '3'); // Float32Array [ 1, 2, 3 ]
console.log(a);
a = Float32Array.of(1, 2, 3);    // Float32Array [ 1, 2, 3 ]
console.log(a);
a = Float32Array.of(undefined);    // Float32Array [ 0 ]
console.log(a);



PreviousNext

Related