SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Feb 2014
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    String concatenation in javascript ?

    Code:
    function(now) {
    			logo.css('transform', 'translate(0px, ' + now + ' px)');
    }
    in this code how is now getting concatenated, i cant understand that part

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,938
    Mentioned
    214 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    maybe an example will help:

    Code:
    function myFunc (now) {
      logo.css('transform', 'translate(0px, ' + now + ' px)');
    }
    
    myFunc(20)
    Will result in:

    Code:
    logo.css('transform', 'translate(0px, ' + 20 + ' px)');
    which is the same as:

    Code:
    logo.css('transform', 'translate(0px, 20px)');
    Make sense?

  3. #3
    SitePoint Member
    Join Date
    Feb 2014
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks its clear now


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
  •