function setProp(object, path, value) {
  var names = path.split(".");
  var prop = names.pop();

  // traverse over the nested objects
  var obj = object;
  for (var i = 0; i < names.length; i++) {
    var name = names[i];
    if (!(name in obj)) {
      obj[name] = {};
    }
    obj = obj[name];
  }

  // set the property value
  obj[prop] = value;

  return object;
}
Set a nested property on an object
When nested objects are missing, they will be created.
For example setProp({}, 'font.color', 'red') will return {font: {color: 'red'}}
@param {object} object
@param {string} path   A dot separated string like 'font.color'
@param {*} value       Value for the property
@returns {object} Returns the original object, allows for chaining.