Last Updated : 12 Jul, 2025
The Javascript Float32Array array represents an array of 32-bit floating-point numbers in the platform byte order. By default, the contents of Float32Array are initialized to 0. The Float32Array.from() method is used to create a new Float32Array from an array-like or iterable object. So when you want to convert an arrayLike or iterable object to Float32Array then you can use this function by passing the object as a parameter to this function along with the map function and value used for the map function if needed.
Syntax:
Float32Array.from( source, mapFn, thisArg )
Parameters: This method accepts three parameters as mentioned above and described below.
Return Value: This method returns a new Float32Array instance.
The below examples illustrate the Float32Array.from() Method in JavaScript:
Example 1: This example shows the basic use of the Float32Array.from() Method in JavaScript.
javascript
// Create a Float32Array from a string like structure
let array = Float32Array.from('7654312456754');
// Print the result
console.log(array);
Output:
7, 6, 5, 4, 3, 1, 2, 4, 5, 6, 7, 5, 4
Example 2: This example shows the basic use of the Float32Array.from() Method in JavaScript.
javascript
// Create a Float32Array from an array by
// multiplying 33.32 to each number using
// function
let array = Float32Array.from([5232.4242,
3114.24551], z => z * 33.32);
// Print the result
console.log(array);
Output:
174344.375, 103766.6640625
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4