Use map() and parseInt()

Copyvar res = ['2', '10', '11'].map(function(v) {
  return parseInt(v, 10);
});

document.write('<pre>' + JSON.stringify(res, null, 3) + '<pre>')
Run code snippetEdit code snippet Hide Results Copy to answer Expand

More simplified ES6 arrow function

Copyvar res = ['2', '10', '11'].map(v => parseInt(v, 10));

document.write('<pre>' + JSON.stringify(res, null, 3) + '<pre>')
Run code snippetEdit code snippet Hide Results Copy to answer Expand

Or using Number

Copyvar res = ['2', '10', '11'].map(Number);

document.write('<pre>' + JSON.stringify(res, null, 3) + '<pre>')
Run code snippetEdit code snippet Hide Results Copy to answer Expand


Or adding + symbol will be much simpler idea which parse the string

Copyvar res = ['2', '10', '11'].map(v => +v );

document.write('<pre>' + JSON.stringify(res, null, 3) + '<pre>')
Run code snippetEdit code snippet Hide Results Copy to answer Expand


FYI : As @Reddy comment - map() will not work in older browsers either you need to implement it ( Fixing JavaScript Array functions in Internet Explorer (indexOf, forEach, etc.) ) or simply use for loop and update the array.

Also there is some other method which is present in it's documentation please look at Polyfill , thanks to @RayonDabre for pointing out.

Answer from Pranav C Balan on Stack Overflow
Discussions

javascript - convert string into array of integers - Stack Overflow
I want to convert the following string '14 2' into an array of two integers. How can I do it ? ... Sign up to request clarification or add additional context in comments. ... +1 and just add polyfill for older browser support if required developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… ... More on stackoverflow.com
🌐 stackoverflow.com
How to convert all elements in an array to integer in JavaScript? - Stack Overflow
I am getting an array after some manipulation. I need to convert all array values as integers. My sample code var result_string = 'a,b,c,d|1,2,3,4'; result = result_string.split("|"); alpha = res... More on stackoverflow.com
🌐 stackoverflow.com
integer - Javascript string to int array - Stack Overflow
Your first iteration calls '1'.charCodeAt('1'). It will parse '1' as a number and try to get the second character code in the string. More on stackoverflow.com
🌐 stackoverflow.com
How can I convert a string to an integer in JavaScript? - Stack Overflow
My prefer way is using + sign, which is the elegant way to convert a string to number in JavaScript. ... Also as a side note: MooTools has the function toInt() which is used on any native string (or float (or integer)). More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
gist.github.com › d1fb87c1c22ef6170c51
JavaScript: convert string array to integer array · GitHub
JavaScript: convert string array to integer array. GitHub Gist: instantly share code, notes, and snippets.
🌐
Bacancy Technology
bacancytechnology.com › qanda › javascript › convert-string-to-integer-in-javascript
How to Convert String to Integer in JavaScript
August 5, 2025 - In JavaScript, you can convert a string to an integer using the following methods: let str = "123"; let num = parseInt(str); console.log(num); // 123 · let str = "123"; let num = +str; console.log(num); // 123 · let str = "123"; let num = Number(str); console.log(num); // 123 ·
Find elsewhere
🌐
RSWP Themes
rswpthemes.com › home › javascript tutorial › how to convert string array element to integer in javascript
How To Convert String Array Element To Integer In Javascript
March 30, 2024 - One of the most efficient ways to convert string array elements to integers is by utilizing the map method. This method allows us to apply a function to each element in the array and return a new array with the transformed values.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-convert-array-of-strings-to-array-of-numbers-in-javascript
How to convert array of strings to array of numbers in JavaScript ? - GeeksforGeeks
July 23, 2025 - In this method, we traverse an array of strings and add it to a new array of numbers by typecasting it to an integer using the parseInt() function.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › parseInt
parseInt() - JavaScript - MDN Web Docs
The parseInt function converts its first argument to a string, parses that string, then returns an integer or NaN. If not NaN, the return value will be the integer that is the first argument taken as a number in the specified radix. (For example, a radix of 10 converts from a decimal number, ...
🌐
Built In
builtin.com › articles › javascript-string-to-a-number
How to Convert a JavaScript String to Number | Built In
One might need to use the parseFloat() method for literal conversion. myString = '129' console.log(parseInt(myString)) // expected result: 129 a = 12.22 console.log(parseInt(a)) // expected result: 12 · More on JavaScriptJavaScript Array Contains: ...
🌐
DEV Community
dev.to › jules_k › array-map-parseint-in-javascript-3ig
Array.map & parseInt in JavaScript - DEV Community
August 18, 2020 - radix: An integer between 2 and 36 that represents the radix (the base in mathematical numeral systems) of the string. We also know that map method expects a callback as an argument. The callback itself can accept 3 arguments: ... Long story short, because we didn't pass the radix number (base) to parseInt, and parseInt is the callback in map, the second argument of the callback in map being the index of each element in the array, the index is passed down to parseInt as its second argument and parseInt "thinks" it is the radix (base) number.
Top answer
1 of 16
3114

The simplest way would be to use the native Number function:

var x = Number("1000")

If that doesn't work for you, then there are the parseInt, unary plus, parseFloat with floor, and Math.round methods.

parseInt()

var x = parseInt("1000", 10); // You want to use radix 10
    // So you get a decimal number even with a leading 0 and an old browser ([IE8, Firefox 20, Chrome 22 and older][1])

Unary plus

If your string is already in the form of an integer:

var x = +"1000";

floor()

If your string is or might be a float and you want an integer:

var x = Math.floor("1000.01"); // floor() automatically converts string to number

Or, if you're going to be using Math.floor several times:

var floor = Math.floor;
var x = floor("1000.01");

parseFloat()

If you're the type who forgets to put the radix in when you call parseInt, you can use parseFloat and round it however you like. Here I use floor.

var floor = Math.floor;
var x = floor(parseFloat("1000.01"));

round()

Interestingly, Math.round (like Math.floor) will do a string to number conversion, so if you want the number rounded (or if you have an integer in the string), this is a great way, maybe my favorite:

var round = Math.round;
var x = round("1000"); // Equivalent to round("1000", 0)
2 of 16
306

Try parseInt function:

var number = parseInt("10");

But there is a problem. If you try to convert "010" using parseInt function, it detects as octal number, and will return number 8. So, you need to specify a radix (from 2 to 36). In this case base 10.

parseInt(string, radix)

Example:

var result = parseInt("010", 10) == 10; // Returns true

var result = parseInt("010") == 10; // Returns false

Note that parseInt ignores bad data after parsing anything valid.
This guid will parse as 51:

var result = parseInt('51e3daf6-b521-446a-9f5b-a1bb4d8bac36', 10) == 51; // Returns true
🌐
OpenReplay
blog.openreplay.com › convert-string-integer-javascript
How to Convert a String to an Integer in JavaScript
February 9, 2025 - The parseInt() function parses a string and returns an integer. It also allows specifying the number system (radix) for conversion. const str = ""42""; const number = parseInt(str, 10); console.log(number); // Output: 42 · The second argument, ...
🌐
Simplilearn
simplilearn.com › home › resources › software development › javascript tutorial: learn javascript from scratch › a guide to convert string to int in javascript
Convert String to an Int (Integer) in JavaScript | Simplilearn
September 16, 2025 - Learn how to convert string to an Int or Integer in JavaScript with correct syntax. Understand how to use the parseInt() method and find out examples for reference.
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
W3Schools
w3schools.com › jsref › jsref_parseint.asp
JavaScript parseInt() Method
The parseInt method parses a value as a string and returns the first integer. A radix parameter specifies the number system to use: 2 = binary, 8 = octal, 10 = decimal, 16 = hexadecimal. If radix is omitted, JavaScript assumes radix 10.
🌐
Flexiple
flexiple.com › javascript › string-to-number
How to Convert a String to a Number In JavaScript - Flexiple
June 6, 2024 - JavaScript provides several methods to achieve this conversion. The parseInt() function parses a string and returns an integer, while the parseFloat() function returns a floating-point number.