Skip to content

Instantly share code, notes, and snippets.

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