• Returns whether each element in the given array is the expected type

    Parameters

    • Optionalarray: null | any[] | readonly any[]

      the array to check

    • Optionaltype: string

      the expected element type

    • relaxed: boolean = false

      treat null as string or object

    Returns boolean

    whether each element in the given array is the expected type

    isTypeof(['foo', 'bar'], 'string');    // true
    isTypeof(['foo', 'bar', null], 'string', true); // true