Код: Выделить всё
myFunction("a.b.c.d.e.f", value)
< /code>
И это вернет мне, как это: < /p>
{ a: { b: { c: { d: { e: { f: value } } } } } }
< /code>
Я начал делать это: < /p>
function myFunction(obj, o) {
let results = []
let sp =obj.split('.')
const firstProperty = sp.shift()
results[firstProperty] = {}
if(sp.length > 0) {
return myFunction(sp.join("."))
}
return results
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... -to-object