Javascript Uint16Array of()

Introduction

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

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

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



PreviousNext

Related