Skip to content

Instantly share code, notes, and snippets.

View vladilenm's full-sized avatar
🎯
Focusing

Vladilen vladilenm

🎯
Focusing
View GitHub Profile
@vladilenm
vladilenm / index.html
Created September 27, 2022 07:59
New HTML Tags
<!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>Rare html tags</title>
<style>
dialog::backdrop {
const myNumber = 42
localStorage.removeItem('number')
console.log(localStorage.getItem('number'))
localStorage.setItem('number', myNumber.toString())
console.log(localStorage.getItem('number'))
localStorage.clear()
const object = {
name: 'Max',
function calcValues(a, b) {
return [
a + b,
a - b,
a * b,
a / b
]
}
const [sum, sub = 'Вычитания нет', mult, ...other] = calcValues(42, 10)
const citiesRussia = ['Москва', 'Санкт-Петербург', 'Казань', 'Новосибирск']
const citiesEurope = ['Берлин', 'Прага', 'Париж']
const citiesRussiaWithPopulation = {
Moscow: 20,
SaintPetersburg: 8,
Kazan: 5,
Novosibirsk: 3
}
@vladilenm
vladilenm / Composition.js
Last active May 24, 2023 13:22
Inheritance vs Composition in JavaScript
function createProgrammer(name) {
const programmer = {name}
return {
...programmer,
...canCode(programmer)
}
}
function canCode({ name }) {
return {
const person = {
name: 'Владилен'
}
function info(phone, email) {
console.log(`Имя: ${this.name}, Тел.:${phone}, Email: ${email}`)
}
// Demo
// info.bind(person)('12345', 'v@mail.ru')
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="X-UA-Compatible" content="ie=edge"/>
<title>JavaScript Debugging</title>
<link
rel="stylesheet"
const day = d => moment(d, 'dddd').format('ddd')
const decimal = time => moment().startOf('d').add(time, 'h')
const interval = ({start, end}) => {
const f = 'h:mm A'
return `${decimal(start).format(f)} - ${decimal(end).format(f)}`
}
const toHTML = item => `<li>${item}</li>`
@vladilenm
vladilenm / JavaScript Fetch.js
Last active March 1, 2024 02:28
JavaScript Fetch + XMLHttpRequest
const requestURL = 'https://jsonplaceholder.typicode.com/users'
function sendRequest(method, url, body = null) {
const headers = {
'Content-Type': 'application/json'
}
return fetch(url, {
method: method,
body: JSON.stringify(body),
@vladilenm
vladilenm / 18 способов сократить JS код.js
Last active March 21, 2023 20:53
18 способов сократить JS код
// 1
const num = 42
// let result
//
// if (num > 20) {
// result = 'More than 20'
// } else {
// result = 'Less than 20'
// }