Phaser API Documentation

  Version: 
<static> SetValue(source, key, value)

Description:

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

Parameters:

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.

Returns:
Description:

true if the property key was valid and the value was set, otherwise false.

Type:
  • boolean
Since: 3.17.0