Javascript Int16Array of()

Introduction

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

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

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



PreviousNext

Related