I've got an empty object and a string:
var obj = {};
var str = "a.b.c";
Is there a way I can turn this into
obj = { a: { b: { c: { } } } }
I can't quite wrap my head around this one and I'm not even sure if it would be possible.
I've got an empty object and a string:
Is there a way I can turn this into
I can't quite wrap my head around this one and I'm not even sure if it would be possible. |
|||||||||||||||||||||
|
|
|||||||||||||||||||||
|
This is from the yui2 yahoo.js file.
See the source for documentation. https://github.com/yui/yui2/blob/master/src/yahoo/js/YAHOO.js |
|||
|
This recursive function returns you the string representation of the desired object
Now you can convert the output of getObjectAsString into object using
EDIT: Removed 'Input as String' version as it works only for single letter subparts in the namespace such as the one given in the question (a.b.c) which is generally not the case. |
||||
|
Here you go:
|
|||||||||||||
|
Here's my take on it:
|
|||
|