Spec-Zone.ru › ColdFusion

arrayIsDefined

Determines whether an array element is defined in a given index.

arrayIsDefined(array, index) → returns boolean

Member Function Syntax

someArray.isDefined(index)

  • CF8+
  • Lucee
  • BL 1.0.0+
  • See Also: ArrayIsEmpty

    Argument Reference

    array string
    Required

    The array object

    index numeric
    Required

    The index to check.

    Examples
    Sample code invoking the arrayIsDefined function

    Simple example

    CF 8+ To check an array element is define or not

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

    Expected Result: Yes

    Simple example

    Lucee 4.5+ To check an array element is define or not

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

    Expected Result: false

    Simple example with two dimensional array

    CF 8+ To check an array element is define or not

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

    Expected Result: No

    Simple example with two dimensional array

    Lucee 4.5+ To check an array element is define or not

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

    Expected Result: true

    © 2012–present Foundeo, Inc. and the CFDocs contributors.
    Licensed under the MIT License.
    ColdFusion is a trademark of Adobe Systems Incorporated.
    https://cfdocs.org/arrayisdefined

    Spec-Zone.ru

    Настройки Оффлайн Что нового Помощь О нас
    Spec-Zone .ru
    спецификации, руководства, описания, API