const obj = { inner: { test: { value: "hello world" } } };
const path = "inner.test.value";
function getByPath() {
}
console.log(getByPath(obj, path)); // Должно вывести "hello world"
console.log(getByPath(obj, "inner.test")); // Должно вывести объект { value: "hello world" }
console.log(getByPath(obj, "inner.nonExistentKey")); // Должно вывести undefined
console.log(getByPath(obj, "")); // Должно вывести undefined или объект целиком в зависимости от реализации
Click Run to execute JavaScript.
Code runs in an isolated environment.
Code runs in an isolated environment.