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.
๐ŸŒ
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.
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ parseFloat
parseFloat() - JavaScript | MDN
It stops at the n character, and treats the preceding string as a normal integer, with possible loss of precision. If a BigInt value is passed to parseFloat(), it will be converted to a string, and the string will be parsed as a floating-point number, which may result in loss of precision as well.
Find elsewhere
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
๐ŸŒ
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...
๐ŸŒ
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?

๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-do-i-convert-a-float-number-to-a-whole-number-in-javascript
How do I convert a float number to a whole number in JavaScript?
In the above output users can see that Math.trunc() method has removed the decimal part and Math.round() method has rounded the number to nearest integer. In this approach, we will use the parseInt() method. The parseInt() method extracts the whole number from the float number or string in ...
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
The Web Dev
thewebdev.info โ€บ home โ€บ how to convert int to float with javascript?
How to convert int to float with JavaScript? - The Web Dev
May 30, 2022 - To convert int to float with JavaScript, we can use the toFixed method. ... Sometimes, we want to convert JavaScript array to string.
๐ŸŒ
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 18, 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.