I still wonder, if it's cool to have such a big discussion on how to convert a string into an integer, or if all the java developers laugh at us. :-)
On Feb 23, 5:17 am, Dave Clements <[email protected]> wrote: > +1 for + > > :D > > On Feb 22, 6:18 pm, Mark Hahn <[email protected]> wrote: > > > > > > > > > > +'123 px' > > > NaN > > > And that is exactly correct. '123 px' is not a number. Using that > > "feature" is worse than trusting type coercion. I would never trust that > > in my code, just as I always use === instead of ==. Well actually I use > > "is" in coffee, but that is a different subject. > > > What if your string was accidentally "100%" instead of "100 px"? > > > You said nothing is right for me. I'm just pointing out that was an overly > > broad statement. Using + instead of parseInt *is* exactly right for me. > > > If you want to be able to use '010' to represent 8 and '1xyz' to represent > > 1, then more power to you. I myself will never use parseInt. Not only for > > the behavior but because it takes too much typing, is less succinct and > > therefore is less readable. > > > Compare... > > area = +w * +h > > To ... > > area = parseInt(w, 10) * parseInt(h, 10) -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
