//Literals { var ford = { type: "hybrid", model: "fusion", power: 180, size: "4800/150/130", fuel: "petrol", }; } //Literals expand var ford = { type: "hybrid", [prompt('Введите название ключа')]: [prompt('Введите параметр')].join(' '), power: 180, size: "4800/150/130", fuel: "petrol", }; //Literals copy let property = prompt('Введите свойство') const obj = {...ford} obj.type = property console.log(obj) //Html tree let body = { tagName: 'body', children: [{ tagName: 'div', children: [{ tagName: 'span', children: ["Enter a data please:"] }, { tagName: 'br', }, { tagName: 'input', attrs: { children: { type:'text', id:'name', } }, }, { tagName: 'input', attrs: { children: { type:'text', id:'surname', } }, }] }, { tagName: 'div', children: [{ tagName: 'button', attrs: { [attributes]: "ok", }, children:['OK'] }, { tagName: 'button', attrs: {}, }] }] } body.children[1].children[1].children=["Cancel"]; body.children[1].children[1].attrs.id= "cancel"; //Parent body.children[0].parent = body; body.children[1].parent = body; body.children[0].children[0].parent = body.children[0]; body.children[0].children[1].parent = body.children[0]; body.children[0].children[2].parent = body.children[0]; body.children[0].children[3].parent = body.children[0]; body.children[1].children[0].parent = body.children[1]; body.children[1].children[1].parent = body.children[1]; //destruct array { let arr = [1,2,3,4,5, "a", "b", "c"] let [odd1,even1,odd2,even2,odd3,...arr2]=arr console.log(odd1,even1,odd2,even2,odd3,arr2)//1 2 3 4 5 [ 'a', 'b', 'c' ] } //destruct string { let arr = [1, "abc"] let [number,arr2]=arr let [s1,s2,s3]=arr2 console.log(number,s1,s2,s3)// 1 a b c } //destruct 2 { let obj = { name: 'Ivan', surname: 'Petrov', children: [{name: 'Maria'}, {name: 'Nikolay'}] } let {children:[{name:name1},{name:name2}]}= obj console.log(name1,name2)//Maria Nikolay } //destruct 3 { let arr = [1,2,3,4, 5,6,7,10] let {0:a,1:b,length}= arr console.log(a,b,length)//1 2 8 } //Destructure и Change OK { let attributes = prompt('Введите название атрибута')// это к заданию Change OK let body = { tagName: 'body', children: [{ tagName: 'div', children: [{ tagName: 'span', children: ["Enter a data please:"] }, { tagName: 'br', }, { tagName: 'input', attrs: { children: { type:'text', id:'name', } }, }, { tagName: 'input', attrs: { type:'text', id:'surname', }, }] }, { tagName: 'div', children: [{ tagName: 'button', attrs: { [attributes]: "ok", }, children:['OK'] }, { tagName: 'button', children:["Cancel"], attrs: { id: "cancel" }, }] }] } let {children:[{children:[{children:[textSpan]},{},{},{attrs:{id:textSurname}}]},{children:[{},{children:[textCancel]}]}]}=body//это к заданию Destructure console.log(textSpan,textCancel,textSurname)//Enter a data please: Cancel surname //это к заданию Destructure body.children[1].children[0].attrs.attributes= prompt('Введите значение атрибута');// это к заданию Change OK } //Copy delete { let ford = { type: "hybrid", model: "fusion", power: 180, size: "4800/150/130", fuel: "petrol", }; const obj= {...ford} delete obj[prompt('Введите ключ для удаления')] }