FCF 2.0 development in progress...
> > > >
[News] [Packages API] [Downloads] [Donate to the project] [Contacts]

fcf.prepare() function

object|array fcf.prepare(object a_object, string|[string|object] a_objectPath)

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

object a_object
- The object in which the elements are created

string|[string|object] a_objectPath
- The path to the object. See the description of the function fcf.parseObjectAddress for the rules for compiling the path
Result
object|array
- 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' }