setByDotNotation()
setByDotNotation<
TResult>(obj:Record<string,any>,path:string|number| (string|number)[],value:TResult,merge:boolean):TResult|undefined
Sets value to object using dot notation.
Type parameters
• TResult = unknown
Parameters
• obj: Record<string, any>
Object to set the value to.
• path: string | number | (string | number)[]
Path as a string, separated by dots.
• value: TResult
Any value to be set.
• merge: boolean= false
Returns
TResult | undefined
Example
ts
const obj = { a: 1, b: { c: 2 } };
setByDotNotation(obj, "b.d.e.0", 3);
// results in
{ a: 1, b: { c: 2, d: { e: [3] } } };
Altair GraphQL Client