Question: I have a function with X arguments. I was curious if functions will accept an object which contains the args and still function correctly.

Example:

```
  var x = 0;
  var y = 0;
  var z = "test";
  someFunction(x,y,z);

```

vs

```
  var obj = new Object();
  obj.x = 0;
  obj.y = 0;
  obj.Z = "test";
  somefunction(obj);

```

vs.

```
  var obj = new Array();
  obj.push(0);
  obj.push(0);
  obj.push("test");
  somefunction(obj);

```

I know you could program it to handle it, but i was curious if functions would be able to accept args in different formats as long as they were all there.

**Edit:**

I seem to get a syntax error of sorts when collecting objects together. What do i mean? I mean i have *somefunction* which accepts some args, including callbacks..... so when trying to write it up, and put all the args/callbackks in an Array to do **somefunction.apply(objArray)**, it errors on adding the items into the set. The way i did it was:

```
 x = new Array();
 x = [url, 
function(){
    displayFile(url, 'image', null, ft_id, null, null, null, null, !MA.isiOS());
}, 
function(e){
    if(DEBUG) console.log('Error creating gallery thumbnail');
    alert('There was a problem creating a thumbnail');
    MA.hideMessage();
}
  ];
  newArray.push(x);

```

it seems to mess up on the x definition set up. Does this approach not like setting up callbacks like this?

Answer: 
It will if `obj` is the Array version, and you call it using [`Function.prototype.apply`](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/apply).

```
somefunction.apply(window, obj);

```

The arguments will be passed as individuals
You can do this, but you will have to access the argument's properties by the variable name. Like so

```
var obj = new Object();
obj.x = 0;
obj.y = 0;
obj.z = "test";
somefunction(obj);

function somefunction(param) {
    param.x; //0
    param.y; //0
    param.z; //test
}

```

You can also access a functions arguments with the variable `arguments`.

```
function somefunction() {
    var param = arguments[0];
    param.x; //0
    param.y; //0
    param.z; //test
}

```

Natively, *no* you cannot. Refer to **user1689607**'s answer for a solution.