'javascript typescript create a object

i have a property like this "data.property" = "16165456".. i try to create a object like this

data {
   property : "16"
}

i use split and and loop but not work


    this.returnKey(model, this.to['pro1'], this.model[this.to['pro2']])
returnKey(model: any, name: string, value: string) {

        let nameParts = name.split("."),
            currentObject = model;
        for (let i in nameParts) {
            let part = nameParts[i]
            currentObject[part] = currentObject[part]

            this.currentObject = currentObject[part];
        }

        let part2 = nameParts[1];
        currentObject = value;
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source