Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
My blog. good-code.ru

Denis Belocerkovec belocer

💭
My blog. good-code.ru
View GitHub Profile
@belocer
belocer / index.html
Created Feb 11, 2021
Обработка ошибок в Promise
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Promise Error</title>
<style>img {
max-width: 200px;
}</style>
@belocer
belocer / index.js
Created Feb 9, 2021
ES6 пример наследования
View index.js
// ES6
class ProductES {
constructor(brand, price, discount) {
this.brand = brand;
this.price = price;
this.discount = discount;
}
get brand() {
return this._brand;
@belocer
belocer / js.js
Created Feb 3, 2021
Самописный map
View js.js
const names = ['Denis', 'Ivan', 'Maks', 'Olga']
function mapArray(arr, fn) {
let res = []
for (let i = 0; i < arr.length; i++) {
res.push(fn(arr[i]));
}
return res;
}
@belocer
belocer / index.html
Last active Feb 3, 2021
Vue.js убираем дёргания и отображение интерполяции при загрузки страницы.
View index.html
<style>
[v-cloak] {
display: none;
}
</style>
<div id="app" v-cloak>
</div>
@belocer
belocer / index.js
Last active Oct 6, 2020
forEach filter map reduce find
View index.js
let people = [
{name: 'Mihail', age: 15, budget: 100},
{name: 'Maria', age: 25, budget: 200},
{name: 'Miron', age: 35, budget: 300},
]
people.forEach((person, index, pArr) => {
console.log(person)
console.log(person.name)
console.log(person.age)
@belocer
belocer / map.js
Last active Oct 6, 2020
Объект Map() Object Map()
View map.js
let map = new Map();
map.set('42', 4222);
map.set(42, '4222');
map.set(44, '666');
console.log(map.get('42')); // 4222
console.log(map.has('42')); // true
console.log(map.has(43)); // false
console.log(map.size); // 3
console.log(map);
View index.html
<img src="img/img_x1.jpg"
srcset="img/img_x2.jpg 2x img/img_x3.jpg 3x">
<img src="img/img_x1.jpg"
srcset="img/img_x2.jpg 500w img/img_x3.jpg 700w img/img_x4.jpg 1000w">
@belocer
belocer / index.html
Created Oct 2, 2020
SVG Варианты работы
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>svg</title>
<style>
svg {
width: 100%;
height: 100%;
border: 2px solid darkolivegreen;
View gulpfile.js
let preprocessor = 'less';
const { src, dest, parallel, series, watch } = require('gulp');
const browserSync = require('browser-sync').create();
const concat = require('gulp-concat');
const uglify = require('gulp-uglify-es').default;
const sass = require('gulp-sass');
const less = require('gulp-less');
const autoprefixer = require('gulp-autoprefixer');
const gcmq = require('gulp-group-css-media-queries');
@belocer
belocer / index.js
Last active Sep 25, 2020
Генераторы
View index.js
// Generator
function *gen (num = 4) {
for (let i = 0; i < num; i++) {
yield i
}
}
const iter = gen(3)
console.log(iter.next()) // { value: 0, done: false }
console.log(iter.next()) // { value: 1, done: false }