获得徽章 0
- JS 数据和结构类型
6种原始数据类型:
这6种原始数据类型,通过 typeof 操作符判断
1. string
2. number
3. boolean
4. bigint
5. symbol
6. undefined
一种特殊的看起来像是原始类型的类型, null, 可以说是结构类型的占位符typeof null === object
一种结构类型 object typeof instance === object
一种非数据也非结构的类型, function, typeof instance === function展开赞过评论1 - ```js
function throttle(fn, timeout) {
let timeoutId;
return function() {
if (timeoutId) {
return;
}
timeoutId = setTimeout(() => {
fn.apply(this, arguments);
timeoutId = undefined;
}, timeout);
};
}
function debounce(fn, timeout) {
let timeoutId;
return function() {
clearTimeout(timeoutId);
timeoutId = setTimeout(() => {
fn.apply(this, arguments);
}, timeout);
};
}
```
简单的 debounce, throttle 的实现展开评论点赞 - 赞过评论1