I use parseInt and always specify the radix. The Number constructor used as a cast does something totally different. Neither will always do what you want. But if you're looking for an integer from a string, and you don't even control it enough to be sure it doesn't have a "0" at the beginning, parseInt with a radix of 10 is 99% what you want.
:Marco On Tuesday, February 21, 2012 7:06:30 PM UTC-8, Mark Hahn wrote: > > I use pluses without a space so it is quite readable. +a means parseInt. > + a means there is concatenation or addition going on somewhere. It is > quite intuitive. > > On Tue, Feb 21, 2012 at 5:56 PM, Marcel Laverdet <mar...@laverdet.com>wrote: > >> Yeah it's identical to prefix +, just more "english" and doesn't blend in >> with string concatenation. It's totally a matter of preference. I >> personally find that while writing software I'm rarely blocked by raw >> typing speed so I use Number() because it makes +'s less ambiguous when I'm >> reading my code later. >> >> On Tue, Feb 21, 2012 at 7:46 PM, Mark Hahn <m...@hahnca.com> wrote: >> >>> > I just use Number() >>> >>> Doesn't + do the same thing? I'm a lazy typist. >>> >>> -- >>> 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 nodejs@googlegroups.com >>> To unsubscribe from this group, send email to >>> nodejs+unsubscr...@googlegroups.com >>> For more options, visit this group at >>> http://groups.google.com/group/nodejs?hl=en?hl=en >>> >> >> -- >> 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 nodejs@googlegroups.com >> To unsubscribe from this group, send email to >> nodejs+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/nodejs?hl=en?hl=en >> > > -- 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 nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en