Use map() and parseInt()

var 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

var 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

var 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

var 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
🌐
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 - Javascript map() method creates an array by calling a specific function on each element present in the parent array. It is a non-mutating method. Generally, the map() method is used to iterate over an array and call function on every element of the array. Example: In this example, we converts an array of strings into an array of numbers using the map() function, which applies the Number constructor to each element, then prints the resulting array of numbers.
Discussions

How to convert an array of string integers to an array of number integers
Essentially I have a select dropdown that is being populated by an API. If you look at the following code snippet, I essentially created an array of IDs called "first" and made it the value for the first select option above the map that I've done. Now in my handleChange when I log the value of a selected option it returns the value of the given option in an array of string numbers. --> Example... if user selects the second option ['1'] When the user selects 'All IDs' that's where the issue is. When that option is selected whats logged is ---> ['1,2,6,8,15,16,17,20,22,23,24,25,26,27,30,32,33,34,36'] I understand that I could use the split method but it crashes for any other option that's selected. How could i get around that? const DropDown = ({ list = [], title, onChange }) => { const handleChange = (e) => { const { value } = e.target const arr = [value] console.log(arr) // onChange(Number(value)) } const first = list.map((list) => list.id) return ( <> {title} {list.map((item) => ( {item.name} ))} ) } More on reddit.com
🌐 r/learnjavascript
7
4
May 3, 2022
javascript - How to convert a string of numbers to an array of numbers? - Stack Overflow
Ref: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… 2019-08-02T10:27:31.107Z+00:00 ... backquote is string litteral so we can omit the parenthesis (because of the nature of split function) but it is equivalent to split(','). The string is now an array, we just have to map each value with a function returning the integer ... More on stackoverflow.com
🌐 stackoverflow.com
javascript - Converting a array of string to array of Int in JS - Stack Overflow
I know I can do this: a = ['1', '2'] b = [] a.forEach(function(e) { b.push(parseInt(e)); }) b >> [1, 2] I want to learn what is wrong in this? ['1', '2'].map(parseInt) >> [1, NaN] More on stackoverflow.com
🌐 stackoverflow.com
javascript - convert array of strings into array of ints - Stack Overflow
I collect the current value of a range slider every 1 second and store those values in an array. The value are saved as ["34", "23", "21"]. I need them to save as ints like [6, 4, 3, 2] before I ca... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
gist.github.com › d1fb87c1c22ef6170c51
JavaScript: convert string array to integer array · GitHub - Gist
JavaScript: convert string array to integer array · Raw · convertStrArrayToIntArray.js · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
🌐
GitHub
gist.github.com › jaewook77 › d1fb87c1c22ef6170c51
JavaScript: convert string array to integer array · GitHub
JavaScript: convert string array to integer array · Raw · convertStrArrayToIntArray.js · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
🌐
Reddit
reddit.com › r/learnjavascript › how to convert an array of string integers to an array of number integers
r/learnjavascript on Reddit: How to convert an array of string integers to an array of number integers
May 3, 2022 -

I know this might be a silly question to ask but how could one covert the following into an array of numbers...

['1,2,6,8,15,16,17,20,22,23,24,25,26,27,30,32,33,34,36']

🌐
TutorialsPoint
tutorialspoint.com › article › how-to-convert-array-of-strings-to-array-of-numbers-in-javascript
How to convert array of strings to array of numbers in JavaScript?
September 15, 2023 - The most common approaches include using the built-in parseInt() method, the Number() constructor, and the unary + operator. The parseInt() method is a built-in function in JavaScript that takes a string as an argument and returns an integer.
🌐
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.
Find elsewhere
🌐
JavaScript in Plain English
javascript.plainenglish.io › how-to-convert-a-javascript-string-into-an-array-of-integers-5ad8e2ed4435
How to Convert a JavaScript String into an Array of Integers? | by John Au-Yeung | JavaScript in Plain English
April 10, 2025 - To convert a JavaScript string into an array of integers, we can use the JavaScript string’s split method with the array filter method to keep only the numbers.
🌐
Stack Overflow
stackoverflow.com › questions › 43221682 › converting-a-array-of-string-to-array-of-int-in-js
javascript - Converting a array of string to array of Int in JS - Stack Overflow
I know I can do this: a = ['1', '2'] b = [] a.forEach(function(e) { b.push(parseInt(e)); }) b >> [1, 2] I want to learn what is wrong in this? ['1', '2'].map(parseInt) >> [1, NaN]
🌐
Coderwall
coderwall.com › p › 4dwucw › convert-string-array-to-int-array-3-steps
Convert string array to int array - 3 steps! (Example)
February 25, 2016 - char[] delimiters = new char[] { ',' }; string[] stringArray = "1,2,3,4,5".Split( delimiters ); int[] intArray = Array.ConvertAll( stringArray, s => int.Parse( s ) );
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-convert-array-of-strings-to-array-of-numbers
Convert Array of Strings to Array of Numbers in JavaScript | bobbyhadz
March 2, 2024 - The Array.map method doesn't change the contents of the original array, it returns a new array. You can also use the Number() constructor and the unary plus (+) operator to convert a string to a number.
🌐
Laracasts
laracasts.com › discuss › channels › laravel › convert-string-array-to-array-of-ints
convert string array to array of int(s)
Continue the code from Brauson only use json_decode first in your string. $integerIDs = array_map('intval', json_decode($string, true));
🌐
Coding Beauty
codingbeautydev.com › home › posts › how to convert a string of numbers to an array in javascript
How to Convert a String of Numbers to an Array in JavaScript - Coding Beauty
July 8, 2022 - Apart from the Number constructor, we can also convert each item in the string array to a number with parseInt(): const str = '1,2,3,4'; const nums = str.split(',').map((item) => parseInt(item, 10)); console.log(nums); // [ 1, 2, 3, 4 ] parseInt() ...
🌐
QuickRef.ME
quickref.me › home › how to convert an array of strings to numbers in javascript - quickref.me
How to convert an array of strings to numbers in JavaScript - QuickRef.ME
In this Article we will go through how to convert an array of strings to numbers only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.