#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    8
    Rep Power
    0

    Help Me !!! (Object Literal in Function Call)


    what does this mean?
    (its pure javascript)

    sample( { name1 : 10 , name2 : 20 } )

    thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2011
    Posts
    118
    Rep Power
    50
    There's no context or specificity in your question, so this is a bit of a stab in the dark.

    It looks like there is a function sample() that takes an object as a parameter, which is being defined in the parameter list at call time.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    8
    Rep Power
    0

    tx


    well i gues u are right, thats a function, i wondered what kinda structure is that !! thats calling the "sample" function, tx a lot

    and the code is this if u like to take a look

    <script>


    var img = document.getElementById('ball')
    img.onclick = function() {

    var height = document.getElementById('field').clientHeight - img.clientHeight
    var width = 100

    animate({
    delay: 20,
    duration: 1000,
    delta: makeEaseOut(bounce),
    step: function(delta) {
    img.style.top = height*delta + 'px'
    }
    })

    }

    </script>
  6. #4
  7. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,041
    Rep Power
    119
    It looks like a pseudo function (not one of JavaScripts global functions); that is using JSON, for a parameter.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    8
    Rep Power
    0
    i see i just do not know about this structure

    { name1 : 10 , name2 : 20 }

    what is that ?
  10. #6
  11. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,301
    Rep Power
    7170
    It defines a new object with two member variables (name1 and name2) and their corresponding values (10 and 20).
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    8
    Rep Power
    0
    Originally Posted by E-Oreo
    It defines a new object with two member variables (name1 and name2) and their corresponding values (10 and 20).
    tx a lot

IMN logo majestic logo threadwatch logo seochat tools logo