Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9187177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:42:19+00:00 2026-06-17T19:42:19+00:00

Possible Duplicate: javascript – Array.map and parseInt I stumbled across the following code snippet:

  • 0

Possible Duplicate:
javascript – Array.map and parseInt

I stumbled across the following code snippet:

> ['10','10','10','10','10'].map(parseInt);
[10, NaN, 2, 3, 4]

What’s happening here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:42:20+00:00Added an answer on June 17, 2026 at 7:42 pm

    Start by consulting the documentation for Array.prototype.map. The key is this line:

    callback is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.

    (emphasis mine)

    Then check the documentation for parseInt:

    The parseInt function converts its first argument to a string, parses it, and returns an integer or NaN. If not NaN, the returned value will be the decimal integer representation of the first argument taken as a number in the specified radix (base). For example, a radix of 10 indicates to convert from a decimal number, 8 octal, 16 hexadecimal, and so on. For radices above 10, the letters of the alphabet indicate numerals greater than 9. For example, for hexadecimal numbers (base 16), A through F are used.

    and:

    If radix is undefined or 0, JavaScript assumes the following:

    • If the input string begins with "0x" or "0X", radix is 16 (hexadecimal).

    • If the input string begins with "0", radix is eight (octal). This feature is non-standard, and some implementations deliberately do not support it (instead using the radix 10). For this reason always specify a radix when using parseInt.

    • If the input string begins with any other value, the radix is 10 (decimal).

    So the first call is:

    parseInt('10',0, ['10','10',...]) // => 10 (because radix=0)
    

    the second is:

    parseInt('10',1, ['10','10',...]) // => NaN because radix is 1
    

    the third:

    parseInt('10',2, ['10','10',...]) // => 2 because 10 in binary is the number "2"
    

    and so on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: javascript - Array.map and parseInt I saw this example of strange JavaScript
Possible Duplicate: Javascript Closure Problem In the following code, TrueThis.aChoices[i]['CallBack'] is a function when
Possible Duplicate: Javascript syntax: what comma means? I came across the code while reading
Possible Duplicate: JavaScript: why does parseInt(1/0, 19) return 18? Why does parseInt(1/0, 19) evaluate
Possible Duplicate: JavaScript: immediate function invocation syntax A similar question has been asked here
Possible Duplicate: Javascript: Setting window.location.href versus window.location When I tested these code in browser
Possible Duplicate: Javascript array sort and unique I was surprised to see that there
Possible Duplicate: Javascript - array.contains(obj) What's wrong with this: var zipCodes =(['90001','90002','90003']); Test if
Possible Duplicate: Javascript sleep How to delay execution in between the following in my
Possible Duplicate: JavaScript: Know when an image is fully loaded I have this code:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.