Skip to content

Instantly share code, notes, and snippets.

View zhongyangxun's full-sized avatar
🦄
Slow down

zhongyangxun zhongyangxun

🦄
Slow down
View GitHub Profile
const baiduMap = {
show() {
console.log('开始渲染百度地图。')
}
}
const renderMap = (map) => {
map.show()
}
class Computer {
constructor(mouse: string, keyboard: string, monitor: string) {}
}
class ComputerBuilder {
mouse: string;
keyboard: string;
monitor: string;
addMouse(mouse: string) {
interface Computer {
run: () => void;
}
class Windows implements Computer {
run() {
console.log('Windows')
}
}
@zhongyangxun
zhongyangxun / debounce.js
Last active March 5, 2021 05:13
JavaScript debounce function.
function debounce(func, wait = 200, immediate) {
let timeout = null;
let context = null;
let args = null;
let previous = null;
let result = null;
function later() {
var passed = Date.now() - previous;
if (passed < wait) {