Aller au contenu principal
Version: Next

safelyGet

Callable

  • safelyGet(list: string | string[], obj?: Record<string, unknown>): any

  • @example
    safelyGet(['a','b'],{a: {b: 2}})  // => 2
    safelyGet(['a','b'],{c: {b: 2}}) // => undefined
    safelyGet(['a','1'],{a: {"1": 2}}) // => 2
    safelyGet(['a','1'],{a: {b: 2}}) // => undefined
    safelyGet('a.b',{a: {b: 2}}) // => 2
    safelyGet('a.b',{c: {b: 2}}) // => undefined
    @since

    2.0.0