@pengzhanbo/utils - v3.4.1
    Preparing search index...

    Function objectGet

    • Retrieve a value from an object using dot path

      使用 dot path 从一个对象中获取一个值

      Type Parameters

      • T extends Record<PropertyKey, any>
      • P extends string

      Parameters

      • source: T

        The source object. 源对象

      • path: P

        The dot path to retrieve. 要获取的路径

      Returns ObjectGet<T, P>

      The value at the specified path. 指定路径处的值

      objectGet({ a: 1 }, 'a') // => 1
      objectGet({ a: { b: 2 } }, 'a.b') // => 2
      objectGet({ a: [{ b: 2 }], 'a[0].b') // => 2