chiprivers Posted August 19, 2010 Share Posted August 19, 2010 Is it possible to change the type that a variable is being stored as? I have a var which is behaving like a string but contains a number. I am assuming that it is behaving like a string due to the way that its value is extracted and applied to the var. Below is an example to demonstrate what I mean by behaving like a string: var x = 10000; var y = 999; var z = x + y; In my script, the above value for z is displaying as 10000999 when I want it to be adding the values so should be 10999. Is there a way that once a var has a value applied, if it is stored as a string, I can change it to be numerical? Quote Link to comment Share on other sites More sharing options...
chiprivers Posted August 19, 2010 Author Share Posted August 19, 2010 Honestly, I did try google first and couldn't find the answer to this one. But I googled, and googled a bit more and found the solution! parseInt() Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.