0

So I was reading the dynamically named properties, which is similar to what I am wanting to do.

I want to pass in an object to be referenced into my object type.

I have a variable in my object that I want to set.

template.format.bold = true;

I am wanting to pass in the object along with it's property into a function to set a value.

function setItem(item, value) {
    template[item] = value;
}

Then I want to be call the function:

setItem('format.bold', true);

How do I do this?

Error received:

TypeError: Cannot read property 'e' of undefined

Demodave
  • 6,242
  • 6
  • 43
  • 58
  • 1
    The duplicate only tries to read a value for a given path. [How to set object property (of object property of..) given its string name in JavaScript?](https://stackoverflow.com/questions/13719593/how-to-set-object-property-of-object-property-of-given-its-string-name-in-ja) creates properties defined by a given path. – Andreas Aug 07 '18 at 18:31
  • I think for your case, you need to look at the function `ReadValue` posted by hamboy75, your case is using nested properties as format is a property of template and bold is a property of format – Ryan Wilson Aug 07 '18 at 18:32

0 Answers0