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
<template> | |
<section class="media-list"> | |
<media-table | |
:rows="list.list" | |
:sord="list.order.sord" | |
:sidx="list.order.sidx" | |
:page="list.pagination.page" | |
:perPage="list.pagination.perPage" | |
:total="list.total" |
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
(() => { | |
console.clear(); | |
console.log('sum is: ' + sum(1)(2)(3)(4)); | |
function sum(a, b = 0) { | |
const res = a + b; | |
console.log({res, a, b}); |
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
/* | |
* Try to copy&paste to your browser's console | |
* OR open this image: https://user-images.githubusercontent.com/4066435/72851941-f7ec8f00-3ca4-11ea-9840-29511325a772.png | |
*/ | |
function solution(str, maxEquals = 2) { | |
let result = '' | |
let equals = 0 | |
for (const i in str) { | |
const prev = str.charAt(i - 1) | |
const curr = str.charAt(i) |
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 React from 'react'; | |
/** | |
* memoized callback (a.k.a. useCallback) with cleanup ability/feature | |
* | |
* @param {Function} baseCallback callback that returns array with [callback, cleanup] | |
* | |
* callback - which will be passed to React.useCallback | |
* | |
* cleanup - which will be called in React.useEffect's cleanup function |
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
// Run callback with delay | |
const debounce = (delay, callback) => { | |
let timer; | |
return function() { | |
if (timer) clearTimeout(timer); | |
timer = setTimeout(() => callback.apply(this, arguments), delay); | |
}; | |
}; |