What object will this create? I've never seen this declaration before so I'm just wondering.
`myArray([]);
for(someValue = 0; someValue < someOtherValue; i++)
myArray.push(something[i]);
`
Thanks for any insight you can give me.
EDIT : I Update the code some more to gime some more info. myArray doesn't seem like a function to me in the code. This is used in an AjaxCall. Some lines after it is used like this
So unless I missed something I don't think it is a function.
3 Answers 3
[]
is an empty array literal and it's being passed to a function myArray
which accepts an array as an argument. This is not a declaration, it's just a function call. It could be defined like this:
function myArray(array) {
for (var i = 0; i < 5; i++) {
array[i] = i;
}
}
var array = []; // empty array to be filled later
myArray(array);
This fills the array with the numbers from 0 to 4.
Comments
You're calling the function myArray
and passing in any empty array literal, which is defined by these: []
. What's the myArray
function look like?
Comments
If myArray
is a function you are calling then []
will pass an empty array as the first argument to it
Its same as doing
var arr = new Array();
myArray(arr);
myArray
.[]
is an array literal. What is thatmyArray
function?