JSFiddle - React, Tailwind, and code Playground

by Sergei Marochkin

JavaScript

const test = {
    keepThis: true,
    hello: {
        keepThisToo: true,
    },
};

const objectSet3 = (obj, path, value) => {
    obj[ path.length - path[3].length ] = value;
    return true;
}


objectSet3(test, ['hello', 'my', 'dear', 'world'], 12345);

console.log(test);