[Javascript] type casting...

Tim Makins spindrift at oceanfree.net
Sat Jun 28 02:55:53 CDT 2003


To change a string to a number, I use this:

foo = foo - 0;

HTH Tim in Ireland.
PS What on earth does your subject line mean ?

  ----- Original Message ----- 
  From: J.R. Pitts 
  To: javascript at LaTech.edu 
  Sent: 28 June 2003 04:34
  Subject: [Javascript] type casting...


  I don't usually do javascript, but every now and then....

  I am doing some time math. I use the following statement to convert a time string (ie...15:30) to a total number of minutes (ie..930)

   endMinutes=endTime.substring(0,2)*60 + endTime.substring(3,5)*1


  I have to use the ending "*1" to cast the the ending string to a number, so that I get '930' instead of a string concatenation (90030)



  Works fine, but what is the proper javascript way to do this?

  Thanks,

  J.R.



------------------------------------------------------------------------------


  _______________________________________________
  Javascript mailing list
  Javascript at LaTech.edu
  https://lists.LaTech.edu/mailman/listinfo/javascript

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20030628/5eee458d/attachment.htm>


More information about the Javascript mailing list