So I am using Ember JS 2.2 and I have a plain JS object and want to set the value of a nested property. However I don't know if some of the parent properties already exist. If they don't exist I would like to create them as an empty object. Basically I would like to do this:
import Ember from 'ember';
let myObj = {};
Ember.set(myObj, 'first_level.second_level.third_level', 'the value I want to set');
and it look like:
{
"first_level":
{
"second_level":
{
"third_level":"the value I want to set"
}
}
}
I know I could check each level manually and assign it if it doesn't exist but I was hoping Ember has something baked in that can do this. I thought I read that there was an existing way to do this in Ember but can't seem to find it in the docs. Could anyone tell me if I am missing something or will I just have to write my own implementation? Any advice is appreciated. Thanks!