Log in

View Full Version : javascript data type ?


sithum
11-08-2010, 05:54
Hi ,
I am sending a function an array of values
which contain '09' , '15','20' ,...etc
everything is working fine except when I have to do something with '09' it seems to truncate off the zero at the begining and pass to the function a 9 instead of a 09

What I want to know is how do I make the function interpert the value as 09 it seems to be converting the parameter to a number instead of the string value '09'

array[0] = '09';
array[1] = '15';
..etc

Thanks for any help

RyanCahoon
11-08-2010, 17:38
sithum,
can you give more detail about what you're trying to do with the values?

I tried your example:


<html>
<body>
<script type="text/javascript">
var arr = new Array();
arr[0] = '09';
arr[1] = '15';
arr[2] = '20';
for(var i in arr)
document.write(arr[i]+'<br/>');
</script>
</body>
</html>

which seems to render fine as

09
15
20


--Ryan