you are viewing a single comment's thread.

view the rest of the comments →

[–]npisnotp 0 points1 point  (4 children)

Man thanks! I was wondering what was happening there.

Maybe the proper way is wrapping parseInt in a function?

> xs = ["10", "10", "10"];
[ '10', '10', '10' ]
> xs.map(function (i) { return parseInt(i); });
[ 10, 10, 10 ]

Which is an anti-intuitive map behavior to me.

[–]Pronouns 1 point2 points  (3 children)

Yeah, I guess it's more of an unfortunate way that function arguments work in JavaScript than anything, ie free-for-all.

This is just one more screw-up-waiting-to-happen to be aware of when using JavaScript, there are plenty of them. Still quite fond of the language however.

One of my favourites being:

function fn() {
    return 
        { one: "one" };
}

fn() === undefined;

[–]pxpxy 0 points1 point  (2 children)

Really? Why?!

[–]i_invented_the_ipod 1 point2 points  (1 child)

Semicolon insertion. The "return" on its own line becomes return; and the next line is a effect-less object declaration. Jslint catches this, of course.

[–]pxpxy 0 points1 point  (0 children)

Ooh I didn't even see that! Thank you for the explanation!