user1453857
user1453857

Reputation: 207

javascript - 2 ways of defining array

i have some array, and inside array i want to define another array. Are those 2 definitions equal? many thanks :)

args: [{
    key: "data",
    ajaxOptions: {
        url: '/rest/adrestresource/1.0/activedirectory/findgroups%[email protected]%20Bezhesla1%20localhost%20CN=Builtin,DC=lab,DC=local',
        type: "GET",
        dataType: "xml"
    }
}];

args: function () {
    return [{
        key: "data",
        ajaxOptions: {
            url: '/rest/adrestresource/1.0/activedirectory/findgroups%[email protected]%20Bezhesla1%20localhost%20CN=Builtin,DC=lab,DC=local',
            type: "GET",
            dataType: "xml"
        }
    }];
}

It is used for configuring a gadget, documentation says: Either an array of objects or a function that returns one. T First approach is working correctly, but defining array by function returning it is not working :?

Upvotes: 0

Views: 92

Answers (1)

MrCode
MrCode

Reputation: 64536

The first example you have a property that is an array. The second example, it is a method that returns an array, so call it like:

// example 1
var myArray = Something.args; // property

// example 2
var myArray = Something.args(); // method

Upvotes: 2

Related Questions