Function dotProp

Finds a value referenced by a dot-chained property tree, i.e.:

import { dotProp } from '@amjs/js-utils';
const ref: Record<string, any> = { key: { param: 'value' } };
console.log(dotProp(ref, 'key.param')); // 'value'

Can also modify the value within the reference if third argument is passed, i.e.:

dotProp(ref, 'key.param', 'foo');
console.log(ref.key.param); // 'foo'
  • Parameters

    • ref: Record<string, any>

      Where to find the property

    • prop: string

      Dot-chained tree property

    • Optionalvalue: any

      New value to assign

    Returns any

    Current value of the property