Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
var result = (function() {
    // parseInt has an optional parameter, the radix.
    // The map method takes a function with three optional arguments.
    // The second paramater of the map function is what is set as the second argument for the parseInt function. This results in the radix being unintentionally modified.
  
    return ['10','10','10','10'].map(parseInt);
})();
console.log(result); // [10, NaN, 2, 3]
// Demonstration of basically what happens:
var result = (function() {
  return ['10','10','10','10'].map(function(value, index, array) {
    return parseInt(value, index); // index is the radix
  });
})();
console.log(result); // [10, NaN, 2, 3]
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
miguelmotapro
0viewers