bladeedg bladeedg - 1 year ago 109
jQuery Question

How to get items returned from an array in a function

I have a function which returns an array of two variables.

function exampleFunction() {
var variable1 = 'test';
var variable2 = 'test2';

return [variable1, variable2];

Now in another function when I call
how do I get the items from the array that is returned from it.

I have tried using:

if (exampleFunction[0] == true) {
// do code here

Answer Source

To retrieve the values, you need to execute the function.

Update from



exampleFunction()[0] // paints "test"