Stupid Javascript question

Devin Whalen devin-Gq53QDLGkWIleAitJ8REmdBPR1lH4CV8 at public.gmane.org
Fri Feb 11 22:02:09 UTC 2005


On Fri, 2005-02-11 at 16:31 -0500, Taavi Burns wrote:
> On Fri, 11 Feb 2005 16:24:31 -0500, Lance F. Squire <lance-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org> wrote:
> > How do I add two values?
> > 
> > a=2;
> > 
> > A*A=4 but A+A=22
> > 
> 
> Something like String.toInt() ?
> http://www.svendtofte.com/code/usefull_prototypes/
> 

Actually, that function returns an array of integers:

String.toInt  	<string>.toInt()
	This function allows you to quickly transform a string into an array of
ints, much like an char array in C or similar languages. The method
returns the int array, and does not transform the original string.

And the integers are actually charCodes not the actual integer values.
So, if you used A.toInt() and A was 2 then it would return 50 (I am
pretty sure).  And even then it would concat the numbers together so you
would get 5050 when doing A.toInt() + A.toInt();

Plus, it is not part of the core javascript, it is a prototype that the
person who owns that website built.  So in order to use it you would
have to download his code and reference it in your javascript.

There really should be a toInt function or something along those lines
but then as Henry says:

> Yeah, javascript is stupid like that.
> 
> The last two words of that sentence are redundant. :-)

Kinda sums up javascript right there :).


Later



-- 
Devin Whalen
Programmer
Synaptic Vision Inc
Phone-(416) 539-0801
Fax- (416) 539-8280
1179A King St. West
Toronto, Ontario
Suite 309 M6K 3C5
Home-(416) 653-3982


Take back the Web with FireFox....a browser you can trust
www.getfirefox.com

   .-.
   /v\    L   I   N   U   X
  // \\  
 /(   )\
  ^^-^^   

--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list