ArrayIndexExists

Returns whether there exists an item in the array at the selected index.

Method Signature

ArrayIndexExists(array=[array], index=[any])

Arguments

Argument
Type
Required
Description
Default

array

array

true

The array to be searched.

index

any

true

The index to check.

Examples

Simple example

To check an array element is define or not

Run Example

someArray = [ 
	1,
	2,
	3,
	4,
	5
];
writeOutput( arrayIsDefined( someArray, 3 ) );

Result: Yes

Simple example

To check an array element is define or not

Run Example

someArray = [ 
	1,
	2,
	3,
	4,
	5
];
writeOutput( arrayIsDefined( someArray, 6 ) );

Result: false

Simple example with two dimensional array

To check an array element is define or not

Run Example

FirstArray = [ 
	1,
	2,
	3
];
secondArray = [
	11,
	12,
	13
];
combineArray = arrayNew( 2 );
arrayAppend( combineArray, firstArray );
arrayAppend( combineArray, secondArray );
writeOutput( arrayIsDefined( combineArray, 3 ) );

Result: No

Simple example with two dimensional array

To check an array element is define or not

Run Example

FirstArray = [ 
	1,
	2,
	3
];
secondArray = [
	11,
	12,
	13
];
combineArray = arrayNew( 2 );
arrayAppend( combineArray, firstArray );
arrayAppend( combineArray, secondArray );
writeOutput( arrayIsDefined( combineArray, 2 ) );

Result: true

Additional Examples

Run Example

fruitArray = [ 
	"apple",
	"kiwi",
	"banana",
	"orange",
	"mango",
	"kiwi"
];
dump( arrayIsDefined( fruitArray, 3 ) ); // true
// member function
dump( fruitArray.isDefined( 30 ) );
 // false

Last updated

Was this helpful?