SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    KickMe
    SitePoint Community Guest

    ... rest parameter

    Hi all ,
    Existance of a site like php.net for javascript ?
    becouse right now (shure is question) i am stucked with ...rest parameter (probaply you know what is it) . And am wondering how exactly i can use the three dots .
    ???
    function printForm(name:String,address:String,phoneNum:String,
    spouseName:String,...childName:Array) ???
    another example will help me a little , if pleased

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Existance of a site like php.net for javascript ?
    No.
    rest parameter (probaply you know what is it)
    Never heard of it.
    And am wondering how exactly i can use the three dots .
    What three dots? In any case, there's no such thing in js.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    If you are trying to pass a variable number of parameters to a function then you need to process them from the arguments[] array within the function.

    arguments.length will tell you how many parameters were passed.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thinking of '...' you may be a 'C' programmer... me too

    felgall is right as rain...
    Code:
    foo(1, 'mike'); 
    
    function foo(arg1)
    {
      alert(arguments.length); // "2"
      alert(arg1); // "1"
      alert(arguments[0]); // "1"
      alert(arguments[1]); // "mike"
      alert(typeof arguments[2]); // "undefined"
    }
    arguments is a local variable within all Functions.


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
  •