Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS

Basic JavaScript

JS Tutorial JS Introduction JS Where To JS Output

JS Syntax

JS Syntax JS Statements JS Comments JS Variables JS Let JS Const JS Types

JS Operators

JS Operators

JS If Else

JS If Conditions

JS Loops

JS Loops

JS Strings

JS Strings

JS Numbers

JS Numbers

JS Functions

JS Functions

JS Objects

JS Objects

JS Scope

JS Scope

JS Dates

JS Dates

JS Temporal

JS Temporal  New

JS Arrays

JS Arrays

JS Sets

JS Sets

JS Maps

JS Maps

JS Iterations

JS Loops

JS Math

JS Math

JS RegExp

JS RegExp

JS DataTypes

JS Data Types

JS Errors

JS Errors

JS Debugging

JS Debugging

JS Conventions

JS Style Guide

JS Reference

JS Statements

JS Projects

JS Projects New

JS Versions

JS 2026

JS HTML

JS HTML DOM JS Events

JS Advanced

JS Functions JS Objects JS Classes JS Asynchronous JS Modules JS Meta & Proxy JS Typed Arrays JS DOM Navigation JS Windows JS Web APIs JS AJAX JS JSON JS jQuery JS Graphics JS Examples JS Reference


Typed Array Methods


The from() Method

The from()method creates a new typed array from any iterable object:

Examples

Create a typed array from a string:

const myArr = Int16Array.from("1234567890");
Try it Yourself »

Create a typed array from an array:

const myArr = Int16Array.from([1,2,3,4,5,6,7,8,9,0]);
Try it Yourself »

The of() Method

The of() method creates a new typed array from a number of arguments:

Example

const myArr = Int16Array.of(1,2,3,4,5,6,7,8,9,0);
Try it Yourself »

The constructor.name Property

The constructor.name property returns the name (type) of a typed array:

Example

myArr.constructor.name
Try it Yourself »

The BYTES_PER_ELEMENT Property

BYTES_PER_ELEMENT returns the number of bytes used to store each array element:

Example

myArr.BYTES_PER_ELEMENT
Try it Yourself »

Common Array Methods

Typed Arrays share many methods with Standard Arrays:

  • Iteration: forEach(), map(), filter(), reduce(), reduceRight(), every(), some(), find(), findIndex(), findLast(), findLastIndex().

  • Searching: includes(), indexOf(), lastIndexOf().

  • Manipulation: at(), copyWithin(), fill(), reverse(), set(), slice(), sort(), subarray().

  • Conversion: join(), toLocaleString(), toString().

  • Non-mutating methods: toReversed(), toSorted(), with().


The fill() Method

The fill() method changes all elements in a typed array to a value:

Example

Fill all array elements with a value:

myArr.fill(200);
Try it Yourself »

The fill() method takes two optional arguments: start index and end index:

Example

Fill some array elements with a value:

myArr.fill(200, 0, 3);
Try it Yourself »

The find() Method

The find() method returns the first element that satisfies a test:

Example

myArr.find((x) => x > 18)
Try it Yourself »

The some() Method

The some() method returns true if an element for which a provided function returns true:

Example

myArr.some((x) => x > 18)
Try it Yourself »


Not Available Array Methods

Some array methods are NOT available for typed array.

This is due to the fixed-length nature and the lack of fixed structure.

MethodArrayTyped Array
pop()YesNO
push()YesNO
shift()YesNO
unshift()YesNO
splice()YesNO
flat()YesNO
flatMap()YesNO
concat()YesNO
toSpliced()YesNO

Browser APIs Supporting Typed Arrays

Fetch API Example

fetch(url)
.then(request => request.arrayBuffer())
.then(arrayBuffer =>...);

Canvas Example

const canvas = document.getElementById('my_canvas');
const context = canvas.getContext('2d');
const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
const uint8ClampedArray = imageData.data;


Browser Support

Typed Arrays is an ES6 feature.

ES6 is fully supported in all modern browsers since June 2017:

Chrome
51
Edge
15
Firefox
54
Safari
10
Opera
38
May 2016 Apr 2017 Jun 2017 Sep 2016 Jun 2016

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.

-->