SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2002
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Convert Into to String?

    Hi, im just starting to learn Javascript, and am wondering if there is anyway I can take an int and convert it into a string... ?? any help would be appreciated. Thanks.

  2. #2
    SitePoint Guru dale_burrell's Avatar
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You probably don't have to do anything - JavaScript is a very loosly typed language and basically it treats any given variable as whatever type best suits the operation.

    So you might not even have an int However if you so then either:

    var Int = 1;
    var Temp = "" + 1;

    or

    var Int = 1;
    var Temp = Int.toString();
    If you aren't living life on the edge
    - you're taking up too much space
    Creative Dreaming Ltd / Ask The Local / Amanzi Travel

  3. #3
    SitePoint Evangelist
    Join Date
    Nov 2002
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Mind,

    You can use the following:

    Code:
    var iNum = 145;
    
    var sString = iNum.toString();
    or

    Code:
    var iNum = 145;
    
    var sString = iNum + '';

  4. #4
    SitePoint Enthusiast
    Join Date
    Sep 2002
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    int to string

    Thanks, I will try that.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •