const prepareShareItems = ({person,items}) => {
for (var i = 0 , res = {} ; i < SECTIONS.length; i++) {
const {slide,list} = person[SECTIONS[i]];
Object.assign(res,{[SECTIONS[i]]: items.find((item) => item.id === list[slide]).image})
}
return res;
};
const APi_URL = 'https://jsonplaceholder.typicode.com/posts'
fetch(APi_URL)
.then( response => response.json())
.then ( posts => {
const post = posts.find(({id}) => id == 53 )
delete posts[post.id]
console.log(posts[post.id]) //undefined
})
.catch((err) => console.log(err));
img {
width: 400px;
height: 400px;
}
<img id="img" src="" alt="">
<button id="button">clickMe</button>
const imgs = ["https://w-dog.ru/wallpapers/13/0/473137029168931/art-chelovek-shhit-pole-cvety-rozy-noch.jpg","https://w-dog.ru/wallpapers/13/16/324755354526701/art-derevo-pejzazh-cvety-deti-zhenshhina-stranicy-trava.jpg"]
button.onclick = () => {
const randomImg = imgs[Math.floor(Math.random() * imgs.length)];
img.setAttribute("src",randomImg)
}
const obj = {
obj2: {
obj3: {
target: 'something',
arr3: [1, 2, [3, 4]],
},
},
}
const path = 'obj2.obj3.target'
const path2 = 'obj2.obj3.arr3[2][0]'
function getProperty (path,obj) {
path = path.replace(/(\.)|(\[)|(\s)/gm,".").replace(/\]/gm,"").split(".")
return path.map((prop) => obj = obj[prop]);
}
console.log( [...getProperty(path,obj)].pop())
console.log( [...getProperty(path2,obj)].pop())
<div class="container">
<div class="container-wrapper">
<!-- сюда контент -->
</div>
<div class="container-background"><img src="" alt=""></div>
</div>
И вы все костыльно сделали