Imagine I have some javascript object eg var person = {};
and I am given a string that represents a dotted traversal into that object eg "Address.Suburb"
and another string that represents the value to be set. eg "Your Town"
What is a general function to enable this to be set. The properties may or may not exist prior to invocation, the function will need to create the properties if necessary.
function MySetter(object, stringTraversal, valueToSet) {
....
}
such that
var person = {};
MySetter(person, "Address.Suburb", "CrazyTown")
alert(person.Address.Suburb); // alerts CrazyTown
Thanks.