- Print
- DarkLight
- PDF
Description
Type: Array
Returns a Javascript array of all input arguments to the active script.
Array is a programming term for a collection.
Examples
// display the 1st and 3rd input arguments in the debugger
var first = script.args[0];
var third = script.arg[2];
debug.log(first);
debug.log(third);
// display # of input arguments to script
// note: Javascript arrays support a 'length' property
var size = script.args.length;
debug.log(size);
Remarks
Access items in this array by specifying their position within square brackets. This is how all Javascript arrays (collections) work. See included examples.
Items in this array are zero-indexed, which means that the first item is at location zero (0), the second at location one (1), and so on.
Programmers are a little strange sometimes. While far more intuitive to think of the first item in a collection as being at location 1, the second at location 2, and so on, programmers made it difficult on themselves and start at position zero!
The 'Ux.Change' event is an example where input arguments are very useful. When this runtime event triggers a script, the script.args property provides access to the specific items in your app's visual layout that were changed by the user.