Wrox Programmer Forums
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 20th, 2008, 05:34 PM
Registered User
 
Join Date: Feb 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default arguments relay

Hi!

    I'd like to know if arguments relay is possible. For example, I have the following function:

    function abc() {
        console.log(arguments);
    }

    and I would like have the following function like:

    function xyz() {
        abc(%[something, arguments]%);
    }

    In other words, I want to relay the same arguments, with no consideration for their count, and add an other one with them.

    Precision: I don't want to do «abc(something, arguments)» since the parameters to abc will be only two, the second being an array... :)

    Any idea? Is it clear? ^^'

    Thanks,

Pierre

 
Old February 20th, 2008, 06:04 PM
Registered User
 
Join Date: Feb 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK guys, I found it... I just have to call the «apply» method of my function with the new collection of parameters. :)

Code:
function abc(a, b, c, d, e) {
    console.log(a, b, c, d, e);
}

function xyz() {
    var a = $A(arguments);
    a.push(4);
    abc.apply(null, a);
}

xyz(1,2,3);





Similar Threads
Thread Thread Starter Forum Replies Last Post
Query w/ arguments darkhalf Access VBA 2 March 3rd, 2008 10:04 AM
Relay Access Denied ajit Java Basics 0 December 28th, 2007 07:25 AM
multiple arguments MunishBhatia C# 2 December 8th, 2006 07:34 AM
Arguments snowy0 VB.NET 2002/2003 Basics 3 September 3rd, 2004 08:40 AM
Program arguments bramtram VB How-To 1 August 14th, 2003 03:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.