Skip to content

Function_evisit_core_js_utils_set

Wyatt Greenway edited this page Jan 31, 2017 · 4 revisions

function set(obj, path, value)

Parameters

  • obj
    • (Object) >>> Object to set property on
  • path
    • (String) Dot notation path to evaluate
  • value
    • (*) Value to set

Return value

  • (String) Return the actual final path (relative to the base object) where the property was set. This is useful if property was pushed into an array; the actual array index will be returned as part of the final path

Description

Notes

  • With empty array notation in a specified path (i.e my.array.key[]) the value will be appended to the array specified

See Also

Examples

var obj = {};
utils.set(obj, 'hello.world', '!!!'); //hello.world
utils.set(set, "arr[]", [1]); //arr[0]
utils.set(obj, "arr[0][1]", 2); //arr[0][1]
utils.set(obj, "arr[]", 3); //arr[1]

Clone this wiki locally