473,382 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Javsahit typing

God., t took me an hour last night to add two numbers together..

Yo would have thought that the people who dreamed up this shit could
have made a slightly more sensible way of arranging typing than to
declare all variables typeless, and have a function to turn a typeless
thing into a number so that you could actually make '10'+'5' not be '105'...

Makes you long for C...
Oct 17 '07 #1
5 1075
On Oct 17, 6:13 am, The Natural Philosopher <a...@b.cwrote:
God., t took me an hour last night to add two numbers together..

Yo would have thought that the people who dreamed up this shit could
have made a slightly more sensible way of arranging typing than to
declare all variables typeless, and have a function to turn a typeless
thing into a number so that you could actually make '10'+'5' not be '105'...
<URL: http://www.jibbering.com/faq/#FAQ4_21>

It works as advertised: see Standard ECMA-262 section 11.6.1.

Peter

Oct 17 '07 #2
On Oct 17, 9:13 pm, The Natural Philosopher <a...@b.cwrote:
God., t took me an hour last night to add two numbers together..

Yo would have thought that the people who dreamed up this shit could
have made a slightly more sensible way of arranging typing than to
declare all variables typeless, and have a function to turn a typeless
thing into a number so that you could actually make '10'+'5' not be '105'...

Makes you long for C...
you can use parseFloat(String) or parseInt(String) to change the type
to what you want

Oct 18 '07 #3
xhy_China said the following on 10/17/2007 11:01 PM:
On Oct 17, 9:13 pm, The Natural Philosopher <a...@b.cwrote:
>God., t took me an hour last night to add two numbers together..

Yo would have thought that the people who dreamed up this shit could
have made a slightly more sensible way of arranging typing than to
declare all variables typeless, and have a function to turn a typeless
thing into a number so that you could actually make '10'+'5' not be '105'...

Makes you long for C...

you can use parseFloat(String) or parseInt(String) to change the type
to what you want
You can use them to change to Numbers, but not "what you want" as
neither will convert to anything but Number.

As for parseInt, be very careful with it or you might be back asking the
question in the FAQ with parseInt.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Oct 18 '07 #4
On 10 17 , 9 13 , The Natural Philosopher <a...@b.cwrote:
God., t took me an hour last night to add two numbers together..

Yo would have thought that the people who dreamed up this shit could
have made a slightly more sensible way of arranging typing than to
declare all variables typeless, and have a function to turn a typeless
thing into a number so that you could actually make '10'+'5' not be '105'...

Makes you long for C...
you can use parseFloat or parseInt

Oct 18 '07 #5
In comp.lang.javascript message <11***************@proxy01.news.clara.ne
t>, Wed, 17 Oct 2007 14:13:20, The Natural Philosopher <a@b.cposted:
>God., t took me an hour last night to add two numbers together..
Before trying to program in a language, one should try to learn
something about it and to appreciate how much or how little one knows.
>Yo would have thought that the people who dreamed up this shit could
have made a slightly more sensible way of arranging typing than to
declare all variables typeless, and have a function to turn a typeless
thing into a number so that you could actually make '10'+'5' not be
'105'...
They did. If you had read the FAQ carefully you would have seen it. If
the FAQ were better written, you would not have needed to read it so
carefully. See also <URL:http://www.merlyn.demon.co.uk/js-
maths.htm#UPM>.

And there are occasions when combining '10' and '5' should give '105'...

--
(c) John Stockton, Surrey, UK. ??*@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
Check boilerplate spelling -- error is a public sign of incompetence.
Never fully trust an article from a poster who gives no full real name.
Oct 18 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

53
by: dterrors | last post by:
Will php 6 do strong typing and/or namespaces? I was shocked to find out today that there are some people who actually argue that weak typing is somehow better. I didn't even know there was a...
12
by: Michael Muller | last post by:
Is there currently any plan to introduce static typing in any future version of Python? (I'm not entirely sure that "static typing" is the right term: what I'm talking about is the declaration of...
467
by: mike420 | last post by:
THE GOOD: 1. pickle 2. simplicity and uniformity 3. big library (bigger would be even better) THE BAD:
12
by: Jason Tesser | last post by:
I work for at a college where I am one of 2 full-time developers and we are looking to program a new software package fro the campus. This is a huge project as it will include everything from...
15
by: Premshree Pillai | last post by:
How do I force static typing in Python? -Premshree Pillai ===== -Premshree http://www.qiksearch.com/] ________________________________________________________________________ Yahoo! India...
19
by: bearophile | last post by:
This is my first post here, I hope this is the right place to talk about such things. I have few comments and notes on the Python language. I've just started to learn it; this is negative because...
94
by: Gabriel Zachmann | last post by:
Is it correct to say that strong/weak typing does not make a difference if one does not use any pointers (or adress-taking operator)? More concretely, I am thinking particularly of Python vs C++....
49
by: bearophileHUGS | last post by:
Adding Optional Static Typing to Python looks like a quite complex thing, but useful too: http://www.artima.com/weblogs/viewpost.jsp?thread=85551 I have just a couple of notes: Boo...
0
by: Paddy | last post by:
The official glossary entry here: http://docs.python.org/tut/node18.html#l2h-46 says: " duck-typing Pythonic programming style that determines an object's type by inspection of its method or...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.