Novikov Kirill
Brought to you by Kirill Novikov
Array.prototype.includes(value : any) : boolean
['a', 'b', 'c'].includes('a')
> true
6 ** 2
> 36
Math.pow(6, 2)
async function foo() {}const foo = async function () {};let obj = { async foo() {} }const foo = async () => {};
Object.entries(value : any) : Array<[string,any]>
let obj = { one: 1, two: 2 };for (let [k,v] of Object.entries(obj)) {console.log(`${k}: ${v}`);}
Object.values(value : any) : Array<any>
Object.values({ one: 1, two: 2 })
> [ 1, 2 ]
'x'.padStart(5, 'ab')
> 'ababx'
'x'.padEnd(5, 'ab')
> 'xabab'
const obj = { get es8() { return 888; } };Object.getOwnPropertyDescriptor(obj, 'es8');
{
configurable: true,
enumerable: true,
get: function es8(){}
set: undefined
}
const promises = [new Promise(resolve => resolve(1)),new Promise(resolve => resolve(2)),]for await (const obj of promises) {console.log(obj)}
> 1, 2
const obj = {foo: 1, bar: 2, baz: 3};const {foo, ...rest} = obj;
> foo: 1
> rest: {bar: 2, baz: 3}
promise.then(result => {···}).catch(error => {···}).finally(() => {···});
const RE_DATE = /(?<year>[0-9]{4})-(?<month>[0-9]{2})-(?<day>[0-9]{2})/const matchObj = RE_DATE.exec('1999-12-31');const year = matchObj.groups.year; // 1999const month = matchObj.groups.month; // 12const day = matchObj.groups.day; // 31
const RE_DOLLAR_PREFIX = /(?<=\$)foo/g;'$foo %foo foo'.replace(RE_DOLLAR_PREFIX, 'bar');
> '$bar %foo foo'