Канадский флаг в canvas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function getWeatherAW(product) { | |
| try{ | |
| const result = await fetch(`https://www.food2fork.com/api/search?key=35010e866f7b1df4c7ad06440cfdf955&q=${product}`); | |
| const data = await result.json(); | |
| return data; | |
| } catch { | |
| console.log(error); | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const getIDs = new Promise((resolve, reject) => { | |
| setTimeout(() => { | |
| resolve([522, 687, 456, 333]); | |
| }, 1500); | |
| }); | |
| const getRecipe = recId => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const getIDs = new Promise((resolve, reject) => { | |
| setTimeout(() => { | |
| resolve([522, 687, 456, 333]); | |
| }, 1500); | |
| }); | |
| const getRecipe = recId => { | |
| return new Promise((resolve, reject)=> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Element { | |
| constructor(name, buildYear) { | |
| this.name = name; | |
| this.buildYear = buildYear; | |
| } | |
| } | |
| class Park extends Element { | |
| constructor(name, buildYear, area, numTrees) { | |
| super(name, buildYear); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let arr = [ | |
| {id: 10, text: 'text'}, | |
| {id: 20, text: 'text2'}, | |
| {id: 30, text: 'text3'}, | |
| {id: 40, text: 'text4'}, | |
| {id: 50, text: 'text5'} | |
| ]; | |
| arr.forEach((element, index) => { | |
| element.id = index; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const obj = {a:1, b:1}; | |
| for(let key in obj) { | |
| if(obj.hasOwnProperty(key)) { | |
| console.log (key); | |
| } | |
| } | |
| //Новый вариант | |
| Object.values(obj); | |
| Object.keys(obj); | |
| Object.entries(obj); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| установка куки на 1 минуту | |
| let date = new Date(new Date().getTime() + 60 * 1000); | |
| document.cookie ="name=user; path=/; expires=" + date.toUTCString(); | |
| document.cookie='password=qwerty; path=/; expires=' + date.toUTCString(); | |
| function getCookie(name) { | |
| let matches = document.cookie.match(new RegExp( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| вытащить из localStorage (например объект userName) | |
| arr - массив объектов, например [{name: 'Маша'}, {name: 'Саша'}] | |
| arr = JSON.parse(localStorage.getItem('userName')); | |
| записать в localStorage | |
| localStorage.setItem('userName', JSON.stringify(arr)); |
NewerOlder