# Function getSafe

- getSafe<T>(fn, defaultVal?): T | undefined

- Avoid "can't access property of undefined" errors in a more readable way.

  #### Type Parameters

  - T

  #### Parameters

  - fn: (() => T)

    Function that wraps a nested property access

    - - (): T

      - #### Returns T

  - `Optional` defaultVal: T

    Optional - the value to return if property access failed

  #### Returns T | undefined

  - Defined in jslib/src/lib/utils/getSafe.ts:7