getPath 函数用于读取对象指定路径的值。
import { getPath } from '@movk/core'
const obj = { a: { b: { c: 1, d: undefined }, e: null }, arr: [{ x: 9 }] }
getPath(obj, 'a.b.c') // 1
getPath(obj, 'a.b.d', 42) // 42(d 为 undefined,使用默认值)
getPath(obj, 'a.e', 100) // null(null 不触发默认值)
getPath(obj, 'arr[0].x') // 9
getPath(obj, '') // 返回 obj 本身
getPath(object, path, defaultValue?)读取对象指定路径的值。
undefined 时返回的默认值。b6146 — refactor: 统一源码文件命名为 camelCase