fcf.prepare() function
Package: fcf-framework-core
File: fcf-framework-core:fcf.js
Available from version: 2.0.2
Creates an object or an array at the path specified in the argument if the object does not exist. And returns the specified object.
Arguments
- The object in which the elements are created
- The path to the object. See the description of the function fcf.parseObjectAddress for the rules for compiling the path
Result
- Object at path a_objectPath from object a_object
Example: Function application
{
let object = {}
let subobject = fcf.prepare(object, "field1[[field2]]");
console.log("Object: ", object);
console.log("Subobject: ", subobject);
}
console.log("");
{
let object = {
field1: {
field2: { value: "value" }
}
};
let subobject = fcf.prepare(object, "field1.field2");
console.log("Object: ", object);
console.log("Subobject: ", subobject);
}
Output:
Object: { field1: { field2: [] } }
Subobject: []
Object: { field1: { field2: { value: 'value' } } }
Subobject: { value: 'value' }