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
// 1 | |
const date = new Date(Date.UTC(2020, 11, 20, 3, 23, 16, 738)); | |
console.log(new Intl.DateTimeFormat('pl-PL', {dateStyle: 'full'}).format(date)); | |
// niedziela, 20 grudnia 2020 | |
// 2 | |
const vehicles = ['Motor', 'bus', 'samochód']; | |
const formatter = new Intl.ListFormat('pl', { style: 'long', type: 'conjunction' }); | |
console.log(formatter.format(vehicles)); | |
// Motor, bus i samochód |
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
"window.titleBarStyle": "native" - focus on navbar on alt | |
smooth scroll | |
smooth caret |
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 fs = require('fs'); | |
let rawData = fs.readFileSync('data.json'); | |
let data = JSON.parse(rawData); | |
const convertToNumber = item => { | |
item.workTimeRangeSum = Number(item.workTimeRangeSum.split(':').join('.').replace(/\.3/g, '.5')); | |
return item; | |
} | |
const res = data.workDays | |
.map(item => { |
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
// so, you have list of users like this | |
const users = [ | |
{ id: '1', name: 'hello' }, | |
{ id: '2', name: 'world' }, | |
{ id: '3', name: 'hello' }, | |
{ id: '1', name: 'hello' }, | |
{ id: '1', name: 'hello' }, | |
] |
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
// So, you have input data like this | |
let objArr = [ | |
{ id: 1, name: 'Kamil' }, | |
{ id: 2, name: 'Janusz' }, | |
{ id: 3, name: 'Mariusz' }, | |
{ id: 4, name: 'Alina' }, | |
{ id: 5, name: 'Olo' } ]; |
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
// I think, that this is an interesting answer. Check if object key exists, if yes, double | |
const columns = [ | |
{ name: 'one', title: 'Order Number', id: 1 }, | |
{ name: 'two', title: 'Strawberry', id: 2 }, | |
{ name: 'three', title: 'Vanilla', id: 3 } | |
]; | |
const mapped = columns.map( | |
item => item.id ? item.id = item.id * 2 : item |
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
type HTMLElementEvent<T extends HTMLElement> = Event & { | |
target: T; | |
} | |
let res = allEvents$.subscribe((item: HTMLElementEvent<HTMLButtonElement>) => { | |
console.log(item.target.value); | |
}) |
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
import { from } from "rxjs"; | |
import { filter, reduce } from "rxjs/operators"; | |
let candidates = [ | |
{ name: 'Brendan Eich', experience: 'JavaScript Inventor' }, | |
{ name: 'Emmet Brown', experience: 'Historian' }, | |
{ name: 'George Lucas', experience: 'Sci-fi writer' }, | |
{ name: 'Alberto Perez', experience: 'Zumba Instructor' }, | |
{ name: 'Bjarne Stroustrup', experience: 'C++ Developer' } | |
]; |
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
abstract class Beverage { | |
description: string = "unknown beverage"; | |
public getDescription(): string { | |
return this.description; | |
} | |
public abstract cost(): number; | |
} | |
abstract class CondimentDecorator extends Beverage { | |
abstract getDescription(): string; |
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 Knight { | |
constructor(private name: string, private age: number) { } | |
public getAge(): number { | |
return this.age; | |
} | |
public getName(): string { | |
return this.name; | |
} |