Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in Javascript only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Member List
Calendar
Today's Posts
Home
Forum
Topic
Javascript
converting a number into string
converting a number into string
Collapse
This topic is closed.
X
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
TheKeith
#1
converting a number into string
Jul 20 '05, 11:20 AM
can you convert a number into a string by simply adding a set of quotes like
this: 5 + ""
Thanks
Lee
#2
Jul 20 '05, 11:20 AM
Re: converting a number into string
TheKeith said:[color=blue]
>
>can you convert a number into a string by simply adding a set of quotes like
>this: 5 + ""[/color]
Yes.
alert((5+"").ch arAt(0))
Comment
Post
Cancel
Evertjan.
#3
Jul 20 '05, 11:20 AM
Re: converting a number into string
Lee wrote on 24 okt 2003 in comp.lang.javas cript:[color=blue]
> alert((5+"").ch arAt(0))[/color]
This part of js is not very intuitive, please test thoroughly:
<script>
x = 5 + ""
alert(x) // 5 string
x = x + x
alert(x) // 55 string
y = x + x * 7
alert(y) // 55385 string
y = x * 7 + x
alert(y) // 38555 string
y = y + 1
alert(y) // 385551 string
y = x * 7 + x * 1
alert(y) // 440 number!
y = y + 1
alert(y) // 441 number!
</script>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Comment
Post
Cancel
Previous
template
Next
Working...
OK
OK
Cancel
👍
👎
☕
Comment