Assuming you have an array in a string format, you can use the following regex to match all the decimals and then use .map(Number)

const str = "['6.35', '2.72', '11.79', '183.25']",
      array = str.match(/\d+(?:\.\d+)?/g).map(Number)

console.log(array)

Answer from adiga on Stack Overflow
🌐
Code Highlights
code-hl.com › home › javascript › tutorials
5 Easy Ways to Convert JavaScript Float to Int | Code Highlights
June 4, 2024 - The bitwise OR operator can also convert a float to an integer by truncating the decimal part. ... All these methods are compatible with major web browsers, including Chrome, Firefox, Safari, Edge, and Internet Explorer. This ensures that your code will run smoothly across different environments. In this tutorial, we explored five simple methods to convert a JavaScript float to an int:
🌐
Rip Tutorial
riptutorial.com › float to integer
JavaScript Tutorial => Float to Integer
To convert a float to an integer, JavaScript provides multiple methods.
Discussions

syntax - How do I convert a float number to a whole number in JavaScript? - Stack Overflow
I'd like to convert a float to a whole number in JavaScript. Actually, I'd like to know how to do BOTH of the standard conversions: by truncating and by rounding. And efficiently, not via convertin... More on stackoverflow.com
🌐 stackoverflow.com
Hey JavaScript, can you turn my float into int properly?
For those who haven’t seen this, it’s because parseInt() takes a string argument. 0.0000005 automatically typecasts to the string ‘5e-7’ in scientific notation. parseInt sees the 5, uses it, sees the e which is not a decimal number, and stops. If you do parseInt(0.0000005, 16) to parse the string in base 16, the answer becomes 94 instead of 5 because e is also a hex digit. More on reddit.com
🌐 r/ProgrammerAnimemes
86
1701
February 3, 2022
performance - Fastest way to cast a float to an int in javascript? - Stack Overflow
The issue with bitwise operators ... to 32bit integers in the process, if that is fine for your use-case then go ahead. See MDN docs on bitwise OR, bitwise NOT, bitwise AND and bitwise XOR or their respective ECMAScript documentation. The parseInt function is usually way slower than the alternatives, most likely because it expects a string as parameter. The solution with the modulo operator should be used with caution as it may bite you in the ass sometime due to floating point issues ... More on stackoverflow.com
🌐 stackoverflow.com
[AskJS] Its about time javascript should get a "integer" and "float" data type.
JavaScript numbers are double-precision floating-point values, also known as a double in other languages like C. This covers the "float" side of things. Now, a double-precision floating-point value can perfectly represent integers up to 52 bits, which is a lot bigger than the 32 bits an int can typically store in other languages. JavaScript bitwise operators such as & or | or ^ also convert their values to 32-bit integers before doing their work. So, just use regular JavaScript numbers to perform your integer arithmetic, and then throw in a few | 0 operations if you want the rounding / clamping behavior found in other language's 32-bit int types. In other words, everything you want is already present. More on reddit.com
🌐 r/javascript
46
0
August 10, 2022
🌐
Just Academy
justacademy.co › blog-detail › how-to-convert-float-to-int-in-javascript
How To Convert Float To Int In JavaScript
6) Type Conversion: You can simply convert a float to an integer by assigning it to a variable of type int. JavaScript will automatically truncate the decimal value.
🌐
Delft Stack
delftstack.com › home › howto › javascript › javascript float to int
How to Convert a Float Number to Int in JavaScript | Delft Stack
February 2, 2024 - We can apply the bitwise right shift operator (represented by >> characters). It will convert the float value to an integer. Underneath at the binary level, the bitwise right SHIFT operator shifts the binary bits of the operand to the right ...
🌐
Byby
byby.dev › js-float-to-int
How to convert float to integer in JavaScript
You can use various methods that either round, truncate, or parse the float value. Depending on your specific use case, you can choose the most appropriate method: Using Math.trunc(). This method returns the integer part of a number by removing any fractional digits.
Top answer
1 of 16
2261
var intvalue = Math.floor( floatvalue );
var intvalue = Math.ceil( floatvalue ); 
var intvalue = Math.round( floatvalue );

// `Math.trunc` was added in ECMAScript 6
var intvalue = Math.trunc( floatvalue );

Math object reference


Examples

Positive
// value=x        //  x=5          5<x<5.5      5.5<=x<6  

Math.floor(value) //  5            5            5
Math.ceil(value)  //  5            6            6
Math.round(value) //  5            5            6
Math.trunc(value) //  5            5            5
parseInt(value)   //  5            5            5
~~value           //  5            5            5
value | 0         //  5            5            5
value >> 0        //  5            5            5
value >>> 0       //  5            5            5
value - value % 1 //  5            5            5
Negative
// value=x        // x=-5         -5>x>=-5.5   -5.5>x>-6

Math.floor(value) // -5           -6           -6
Math.ceil(value)  // -5           -5           -5
Math.round(value) // -5           -5           -6
Math.trunc(value) // -5           -5           -5
parseInt(value)   // -5           -5           -5
value | 0         // -5           -5           -5
~~value           // -5           -5           -5
value >> 0        // -5           -5           -5
value >>> 0       // 4294967291   4294967291   4294967291
value - value % 1 // -5           -5           -5
Positive - Larger numbers
// x = Number.MAX_SAFE_INTEGER/10 // =900719925474099.1

// value=x            x=900719925474099    x=900719925474099.4  x=900719925474099.5
           
Math.floor(value) //  900719925474099      900719925474099      900719925474099
Math.ceil(value)  //  900719925474099      900719925474100      900719925474100
Math.round(value) //  900719925474099      900719925474099      900719925474100
Math.trunc(value) //  900719925474099      900719925474099      900719925474099
parseInt(value)   //  900719925474099      900719925474099      900719925474099
value | 0         //  858993459            858993459            858993459
~~value           //  858993459            858993459            858993459
value >> 0        //  858993459            858993459            858993459
value >>> 0       //  858993459            858993459            858993459
value - value % 1 //  900719925474099      900719925474099      900719925474099
Negative - Larger numbers
// x = Number.MAX_SAFE_INTEGER/10 * -1 // -900719925474099.1

// value = x      // x=-900719925474099   x=-900719925474099.5 x=-900719925474099.6

Math.floor(value) // -900719925474099     -900719925474100     -900719925474100
Math.ceil(value)  // -900719925474099     -900719925474099     -900719925474099
Math.round(value) // -900719925474099     -900719925474099     -900719925474100
Math.trunc(value) // -900719925474099     -900719925474099     -900719925474099
parseInt(value)   // -900719925474099     -900719925474099     -900719925474099
value | 0         // -858993459           -858993459           -858993459
~~value           // -858993459           -858993459           -858993459
value >> 0        // -858993459           -858993459           -858993459
value >>> 0       //  3435973837           3435973837           3435973837
value - value % 1 // -900719925474099     -900719925474099     -900719925474099
2 of 16
348

Bitwise OR operator

A bitwise or operator can be used to truncate floating point figures and it works for positives as well as negatives:

function float2int (value) {
    return value | 0;
}

Results

float2int(3.1) == 3
float2int(-3.1) == -3
float2int(3.9) == 3
float2int(-3.9) == -3

Performance comparison?

I've created a JSPerf test that compares performance between:

  • Math.floor(val)
  • val | 0 bitwise OR
  • ~~val bitwise NOT
  • parseInt(val)

that only works with positive numbers. In this case you're safe to use bitwise operations well as Math.floor function.

But if you need your code to work with positives as well as negatives, then a bitwise operation is the fastest (OR being the preferred one). This other JSPerf test compares the same where it's pretty obvious that because of the additional sign checking Math is now the slowest of the four.

Note

As stated in comments, BITWISE operators operate on signed 32bit integers, therefore large numbers will be converted, example:

1234567890  | 0 => 1234567890
12345678901 | 0 => -539222987
Find elsewhere
🌐
W3Schools
w3schools.com › js › js_number_methods.asp
JavaScript Number Methods
Safe integers are all integers from -(253 - 1) to +(253 - 1). This is safe: 9007199254740991. This is not safe: 9007199254740992. For a complete reference to all JavaScript properties and methods, with full descriptions and many examples, go to:
🌐
Itsourcecode
itsourcecode.com › home › converting floats to integers in javascript: 10 effective ways
Converting Floats to Integers in JavaScript: 10 Effective Ways
July 27, 2023 - Find out the different methods to achieve JavaScript float to int conversion effectively. Do you want to know how to convert float numbers...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › parseFloat
parseFloat() - JavaScript - MDN Web Docs
A floating point number parsed from the given string, or NaN when the first non-whitespace character cannot be converted to a number. Note: JavaScript does not have the distinction of "floating point numbers" and "integers" on the language level. parseInt() and parseFloat() only differ in their parsing behavior, but not necessarily their return values.
🌐
Javascriptf1
javascriptf1.com › snippet › convert-a-float-number-to-integer-in-javascript
Convert a float number to integer in JavaScript - JavaScriptF1.com
November 2, 2021 - If you want the integer (whole) part of a float without rounding, you can use the Math.trunc function.
🌐
Reddit
reddit.com › r/javascript › [askjs] its about time javascript should get a "integer" and "float" data type.
r/javascript on Reddit: [AskJS] Its about time javascript should get a "integer" and "float" data type.
August 10, 2022 -

After all the improvements/features and fixes which were made to javascript (or precisely ECMAScript) since ES6 (ES2015) till now (ES2022), isn't it about time to fix the ultimate pending weakness i.e. having an Integer and a Float type as well (just like "var" keyword was/is there but they added "let" and "const" as a better semantics and good practice) and not just mashup everything in Number.

Heck, we even got a big int to represent big integers (no floats allowed) but we still don't have Integer's and Floats which are SUPER useful in almost every scenario.

So, why is it still not added and not planned as well? Those are VERY important data types and MOST languages HAVE those data types as they are NEEDED, why is it not planned for ECMAScript? Is it planned? Do you want to see this added?

🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-convert-a-float-number-to-the-whole-number-in-javascript
How to Convert a Float Number to the Whole Number in JavaScript? - GeeksforGeeks
July 11, 2025 - // float value is 4.59; let x = 4.59; let z = Math.ceil(x); console.log("Converted value of " + x + " is " + z); ... Round a number to its nearest integer.
🌐
Unity
discussions.unity.com › unity engine
[SOLVED] typecast float to int in javascript? - Unity Engine - Unity Discussions
September 18, 2009 - A forum search has lead me to think it’s not doable. “as” only works on reference types and Unity doesn’t dig var f1 : float = 3.14; var myVar : int = (int)f1; or var f1 : float = 3.14; var myVar : int = int(f1);…
🌐
Google
discuss.google.dev › google cloud › apigee
Float is getting converted to either int or string. But we need to pass it as float. - Apigee - Google Developer forums
April 19, 2024 - We’re using javascript to do it as the response payload consists of lots of arrays. Here there’s a field where we receive it as float and we need to pass a float to source systems. But JS is somehow converting the float to int when decimal part contains only zeros.
🌐
W3Schools
w3schools.com › js › js_numbers.asp
JavaScript Numbers
Javascript numbers are always double (64-bit floating point). Integers (numbers without a period or exponent notation) are accurate up to 15 digits.