FAQ Topic - Why does 1+1 equal 11? or How do I convert a string to a number?

F

FAQ server

-----------------------------------------------------------------------
FAQ Topic - Why does 1+1 equal 11? or How do I convert a string to a number?
-----------------------------------------------------------------------

Javascript variables are loosely typed: the conversion between a
string and a number happens automatically. Since plus (+) is also
used as in string concatenation, « '1' + 1 » is equal to « '11' »: the
String deciding what + does. To overcome this, first convert the
string to a number. For example:
« Number(varname) » or « varname*1 » or « varname-0 » or
« parseInt(varname, 10) » or « parseFloat(varname) » or « +varname ».
Prompt and form control values are strings, as is the result from
a prompt window. Convert these to numbers before performing
addition.

Additional Notes:

http://www.jibbering.com/faq/faq_notes/type_convert.html

http://msdn.microsoft.com/library/en-us/script56/html/js56jscondeclare.asp


===
Postings such as this are automatically sent once a day. Their
goal is to answer repeated questions, and to offer the content to
the community for continuous evaluation/improvement. The complete
comp.lang.javascript FAQ is at http://www.jibbering.com/faq/.
The FAQ workers are a group of volunteers.
 
D

Dr J R Stockton

Tue said:
FAQ server wrote on 31 okt 2006 in comp.lang.javascript:
-----------------------------------------------------------------------
FAQ Topic - Why does 1+1 equal 11? or How do I convert a string to a
number?
-----------------------------------------------------------------------
[..]

http://msdn.microsoft.com/library/en-us/script56/html/js56jscondeclare.
asp

Page not found!


If <a href="http://malch.elsop.com/quick.cgi">LinkScan</a> is put in
the FAQ, any reader will readily be able to check all of the external
links in it thereby, for existence if not for relevance.
 
R

Randy Webb

Dr J R Stockton said the following on 10/31/2006 3:40 PM:

If <a href="http://malch.elsop.com/quick.cgi">LinkScan</a> is put in
the FAQ, any reader will readily be able to check all of the external
links in it thereby, for existence if not for relevance.

When feeding the FAQ URL to that site, the only error it comes up with
(aside from newsgroups references) is to the javascript.faqts.com site.
It times out (even me trying to open it).

Possible Error: 903 Connect Timeout http://javascript.faqts.com/
http://javascript.faqts.com/

The actual URL of the page is now:

<URL:
http://msdn.microsoft.com/library/d...html/12a450e5-4818-4a09-9878-cd7c6cd2a248.asp>

Although I did not get a "Page Not Found" from the original URL.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top