Last active
August 29, 2015 14:02
-
-
Save CarstenKoenig/9baa2aad222475347f40 to your computer and use it in GitHub Desktop.
WAT with .map and parseInt
This file contains 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.
Learn more about bidirectional Unicode characters
// Die Frage war, warum | |
["1", "5"].map(parseInt); | |
// schief geht. | |
// Johannes hatte die Antwort, die ich nicht vertanden habe | |
// die Konsole hilft weiter: | |
var f = function() { console.log(arguments); } | |
["1", "5"].map(f) | |
> ["1", 0, Array[2]] | |
> ["5", 1, Array[2]] | |
// sollte ich mir merken , map gibt den Index weiter | |
// wie immer gilt: mit Typen oder wenn `parseInt` | |
// mit falschen Argumenten wie radix=0 richtig | |
// umgehen würde, wäre das nicht passiert |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
RTFM ;) - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map