Sets a value in an object, allowing for dot notation to control the depth of the property.
For example:
var data = {
world: {
position: {
x: 200,
y: 100
}
}
};
SetValue(data, 'world.position.y', 300);
console.log(data.world.position.y); // 300
name | type | description |
---|---|---|
source | object |
The object to set the value in. |
key | string |
The name of the property in the object. If a property is nested, the names of its preceding properties should be separated by a dot ( |
value | any |
The value to set into the property, if found in the source object. |
true
if the property key was valid and the value was set, otherwise false
.