摘要: 1.正常模式 <script src="index.js"></script> 正常模式下js会阻塞dom渲染, 浏览器必须等待js加载执行完后才能做其他事情; 2.async模式 <script async src="index.js"></script> async 模式下, js加载是异步的, 阅读全文
posted @ 2023-02-03 11:12 laiyaoWeb 阅读(80) 评论(0) 推荐(0)
摘要: 实现一个类 const boy = new PlayBoy('Tom'); boy.sayHi().sleep(1000).play('王者').sleep(2000).play('跳一跳') // 输出 // 大家好我是Tom // 1s 之后 // 我在玩王者 // 2s 之后 // 我在玩跳一 阅读全文
posted @ 2023-02-03 10:05 laiyaoWeb 阅读(68) 评论(0) 推荐(0)
摘要: (async () => { const fetchData = () => { return new Promise((resolve, reject) => { setTimeout(() => { resolve('fetch data is me') }, 1000) }) } // 抽离成 阅读全文
posted @ 2023-02-03 10:05 laiyaoWeb 阅读(13) 评论(0) 推荐(0)
摘要: const globalThis = typeof window !== 'undefined' ? window : global; Function.prototype.myCall = function (context, ...args) { if (typeof this !== 'fun 阅读全文
posted @ 2023-02-03 10:05 laiyaoWeb 阅读(15) 评论(0) 推荐(0)
摘要: 查看 npm 的版本 $ npm -v 查看所有命令 $ npm help 查看某条命令的详细帮助 $ npm help <command> 查看各个命令的简单用法 $ npm -l npm init 初始化 npm view 查看模块详细信息 $ npm view <包名> # 别名 info s 阅读全文
posted @ 2023-02-03 09:47 laiyaoWeb 阅读(57) 评论(0) 推荐(0)