This file contains 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
[{ | |
"id": 19112831, | |
"sku": 1120001, | |
"name": "Пицца Пепперони с томатами", | |
"description": "Пицца пепперони - очень популярный вид пиццы как в Европе, так и в Америке. Она получила свое название благодаря основному ингредиенту солями пепперони, который и отличает ее от всех остальных видов пицц. Он имеет острый вкус и при запекании покрывается хрустящей жирной корочкой.", | |
"price": "100", | |
"currency": "UAN", | |
"creatorId": 1, | |
"created": "21-08-2018", | |
"modified": "21-08-2018", |
This file contains 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 person = { | |
name: 'Ivan', | |
age: 24, | |
showInfo() { | |
console.log('Info is: ', this.name, this.age) | |
} | |
}; | |
const person2 = { | |
name: 'Anna', |
This file contains 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
// example 1 | |
let libraryInstance = null; | |
const initLibrary = () => { | |
libraryInstance = { | |
scrollTo() { | |
console.log('scrolling'); | |
} |
This file contains 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 counter = (function (argument) { | |
let count = 0; | |
const increase = () => { | |
count++ | |
}; | |
const decrease = () => { | |
count-- | |
}; |
This file contains 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 promisify = (func) => () => new Promise((resolve) => func(resolve)); | |
const showBackground = (resolve) => { | |
setTimeout(() => { | |
console.log('showBackground works!!!'); | |
resolve(); | |
} , 3000); | |
}; | |
const slideSidebar = (resolve) => { |
This file contains 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 showPokemon = pokemon => { | |
const body = document.querySelector('body'); | |
const image = document.createElement('img'); | |
image.src = pokemon.sprites.front_default; | |
body.appendChild(image); | |
}; |
This file contains 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 showPokemonAsync = (pokemon) => new Promise((resolve, reject) => { | |
const body = document.querySelector('body'); | |
const image = document.createElement('img'); | |
image.src = pokemon.sprites.front_default; | |
image.onload = resolve; | |
image.onerror = reject; | |
body.appendChild(image); |
This file contains 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 Enemy { | |
constructor(config) { | |
const {name, health, attackPoints} = config; | |
this.#name = name; | |
this.#health = health; | |
this.#attackPoints = attackPoints; | |
this.enemyType = config.enemyType; | |
} |
This file contains 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 fetchPokemons = (url) => { | |
return fetch(url).then(response => response.json()); | |
}; | |
// Async example | |
(async () => { | |
const pokemon1 = await fetchPokemons('https://pokeapi.co/api/v2/pokemon/1'); |
This file contains 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
// example for scroll instances caching es6 | |
const scrollInstancesMap = new Map(); | |
| |
const scrollContainer = document.querySelector('.frontpage-content__container'); | |
| |
const currentScroller = scrollInstancesMap.get(scrollContainer); | |
| |
if (currentScroller) { | |
currentScroller.scrollToElement(someElement) |