首页 文章 精选 留言 我的

精选列表

搜索[javascript],共10000篇文章
优秀的个人博客,低调大师

JavaScript 中 at() 方法在数组和字符串中的实际应用与边界处理

在维护一个数据看板项目时,我经常需要从数组或字符串的末尾取元素。以前习惯用 `arr[arr.length - 1]` 或者 `str.charAt(str.length - 1)`,写多了总觉得啰嗦,而且一旦变量名很长,代码读起来就有点费劲。后来发现 ES2022 给数组、字符串和 TypedArray 都加了 `at()` 方法,可以直接传负数索引,从末尾往前数。这个 API 在 Chrome 92+、Node 16.6+ 都已经支持,但实际用的时候有几个细节容易踩坑:比如它不改变原数组,对稀疏数组的处理和普通索引一样,字符串上返回的是单个字符而不是码点。这篇文章会结合几个真实场景,聊聊 `at()` 的用法、和传统写法的对比,以及当索引越界或遇到非整数时它到底返回什么。 ## 从末尾取元素到底有多常见 假设有一个最近访问列表,按时间倒序排列,要拿最近一条记录: ```js const recentVisits = ['/home', '/dashboard', '/settings', '/profile']; // 老写法 const latest = recentVisits[recentVisits.length - 1]; // at() 写法 const latest = recentVisits.at(-1); ``` `at(-1)` 等价于 `length - 1`,但省掉了手动计算。对于 `at(-2)`、`at(-3)` 也一样直观。字符串上同样适用: ```js const fileName = 'report-2024-final.pdf'; const ext = fileName.at(-3) + fileName.at(-2) + fileName.at(-1); // 'pdf' ``` 当然截扩展名有更合适的 `split` 或 `slice`,这里只是展示负数索引在字符串上的表现。 ## 越界和非法参数时返回什么 `at()` 的行为和普通方括号索引在越界时一致:返回 `undefined`,不会抛错。 ```js const arr = [10, 20, 30]; console.log(arr.at(5)); // undefined console.log(arr.at(-5)); // undefined console.log(arr.at(1.5)); // 20?不,是 undefined ``` 最后一行值得注意:`at()` 会把参数先转成整数,但转换规则和 `Array.prototype.slice` 不同。它使用 `ToIntegerOrInfinity`,小数会直接截断。`1.5` 截断成 `1`,所以 `arr.at(1.5)` 实际返回 `20`。我在控制台验证过,确实如此。但如果你传 `NaN`,会被转成 `0`: ```js console.log(arr.at(NaN)); // 10 console.log(arr.at('1')); // 20,字符串 '1' 被转成数字 1 ``` 这些隐式转换在动态数据里容易出问题。比如从 URL query 取到的索引是字符串,直接传给 `at()` 反而能工作,但可读性差,最好显式 `Number()` 一下。 ## 稀疏数组和 at() 的互动 稀疏数组里空槽的行为和普通索引一致: ```js const sparse = [1, , 3]; console.log(sparse.at(1)); // undefined console.log(sparse.at(-2)); // undefined ``` 它不会像 `map` 或 `forEach` 那样跳过空槽,而是直接返回 `undefined`。如果你用 `at()` 来取稀疏数组末尾,得到的就是那个空槽的值。 ## 字符串上的 at() 和 Unicode `String.prototype.at()` 返回的是指定位置的 UTF-16 码元,不是完整码点。对于 emoji 或某些汉字(如 `𠮷`),一个字符占两个码元,`at()` 只取其中一个会得到乱码的一半: ```js const emoji = '😀'; console.log(emoji.at(0)); // '\uD83D' 半个代理对 console.log(emoji.at(1)); // '\uDE00' ``` 要按码点取字符,还是得用 `Array.from(str)` 或者展开运算符。所以 `at()` 适合处理普通 ASCII 或 BMP 内的字符,涉及 emoji 时得留个心眼。 ## 在 React 列表渲染中的一个小优化 之前写一个消息列表,需要取最后一条消息的 id 作为 key 的参考: ```jsx function MessageList({ messages }) { const lastId = messages.at(-1)?.id; return ( {messages.map(msg => ( {msg.text} ))} ); } ``` 这里用了可选链,因为 `messages` 可能为空数组,`at(-1)` 返回 `undefined`,再访问 `.id` 会报错。相比 `messages[messages.length - 1]?.id`,`at()` 写起来更短,意图也更明确。 ## Node.js 中的兼容性处理 如果项目需要支持 Node 14 或更早版本,`at()` 不存在。可以在入口文件加一个轻量 polyfill: ```js if (!Array.prototype.at) { Array.prototype.at = function(index) { const len = this.length; const relativeIndex = Math.trunc(index) || 0; const k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; if (k = len) return undefined; return this[k]; }; } ``` 字符串的 polyfill 类似,但要注意不要直接修改 `String.prototype`,除非你清楚影响范围。更稳妥的做法是用工具函数: ```js function charAt(str, index) { const i = index 推荐查看天气:https://www.0dtq.com/liangzihu/40tian.html 推荐查看天气:https://www.0dtq.com/echeng/ 推荐查看天气:https://www.0dtq.com/echeng/zuotian.html 推荐查看天气:https://www.0dtq.com/echeng/7tian.html 推荐查看天气:https://www.0dtq.com/echeng/10tian.html 推荐查看天气:https://www.0dtq.com/echeng/15tian.html 推荐查看天气:https://www.0dtq.com/echeng/40tian.html 推荐查看天气:https://www.0dtq.com/jingmen/ 推荐查看天气:https://www.0dtq.com/jingmen/zuotian.html 推荐查看天气:https://www.0dtq.com/jingmen/7tian.html 推荐查看天气:https://www.0dtq.com/jingmen/10tian.html 推荐查看天气:https://www.0dtq.com/jingmen/15tian.html 推荐查看天气:https://www.0dtq.com/jingmen/40tian.html 推荐查看天气:https://www.0dtq.com/dongbao/ 推荐查看天气:https://www.0dtq.com/dongbao/zuotian.html 推荐查看天气:https://www.0dtq.com/dongbao/7tian.html 推荐查看天气:https://www.0dtq.com/dongbao/10tian.html 推荐查看天气:https://www.0dtq.com/dongbao/15tian.html 推荐查看天气:https://www.0dtq.com/dongbao/40tian.html 推荐查看天气:https://www.0dtq.com/duodao/ 推荐查看天气:https://www.0dtq.com/duodao/zuotian.html 推荐查看天气:https://www.0dtq.com/duodao/7tian.html 推荐查看天气:https://www.0dtq.com/duodao/10tian.html 推荐查看天气:https://www.0dtq.com/duodao/15tian.html 推荐查看天气:https://www.0dtq.com/duodao/40tian.html 推荐查看天气:https://www.0dtq.com/jingshan/ 推荐查看天气:https://www.0dtq.com/jingshan/zuotian.html 推荐查看天气:https://www.0dtq.com/jingshan/7tian.html 推荐查看天气:https://www.0dtq.com/jingshan/10tian.html 推荐查看天气:https://www.0dtq.com/jingshan/15tian.html 推荐查看天气:https://www.0dtq.com/jingshan/40tian.html 推荐查看天气:https://www.0dtq.com/shayang/ 推荐查看天气:https://www.0dtq.com/shayang/zuotian.html 推荐查看天气:https://www.0dtq.com/shayang/7tian.html 推荐查看天气:https://www.0dtq.com/shayang/10tian.html 推荐查看天气:https://www.0dtq.com/shayang/15tian.html 推荐查看天气:https://www.0dtq.com/shayang/40tian.html 推荐查看天气:https://www.0dtq.com/zhongxiang/ 推荐查看天气:https://www.0dtq.com/zhongxiang/zuotian.html 推荐查看天气:https://www.0dtq.com/zhongxiang/7tian.html 推荐查看天气:https://www.0dtq.com/zhongxiang/10tian.html 推荐查看天气:https://www.0dtq.com/zhongxiang/15tian.html 推荐查看天气:https://www.0dtq.com/zhongxiang/40tian.html 推荐查看天气:https://www.0dtq.com/xiaogan/ 推荐查看天气:https://www.0dtq.com/xiaogan/zuotian.html 推荐查看天气:https://www.0dtq.com/xiaogan/7tian.html 推荐查看天气:https://www.0dtq.com/xiaogan/10tian.html 推荐查看天气:https://www.0dtq.com/xiaogan/15tian.html 推荐查看天气:https://www.0dtq.com/xiaogan/40tian.html 推荐查看天气:https://www.0dtq.com/xiaonan/ 推荐查看天气:https://www.0dtq.com/xiaonan/zuotian.html 推荐查看天气:https://www.0dtq.com/xiaonan/7tian.html 推荐查看天气:https://www.0dtq.com/xiaonan/10tian.html 推荐查看天气:https://www.0dtq.com/xiaonan/15tian.html 推荐查看天气:https://www.0dtq.com/xiaonan/40tian.html 推荐查看天气:https://www.0dtq.com/xiaochang/ 推荐查看天气:https://www.0dtq.com/xiaochang/zuotian.html 推荐查看天气:https://www.0dtq.com/xiaochang/7tian.html 推荐查看天气:https://www.0dtq.com/xiaochang/10tian.html 推荐查看天气:https://www.0dtq.com/xiaochang/15tian.html 推荐查看天气:https://www.0dtq.com/xiaochang/40tian.html 推荐查看天气:https://www.0dtq.com/dawu/ 推荐查看天气:https://www.0dtq.com/dawu/zuotian.html 推荐查看天气:https://www.0dtq.com/dawu/7tian.html 推荐查看天气:https://www.0dtq.com/dawu/10tian.html 推荐查看天气:https://www.0dtq.com/dawu/15tian.html 推荐查看天气:https://www.0dtq.com/dawu/40tian.html 推荐查看天气:https://www.0dtq.com/yunmeng/ 推荐查看天气:https://www.0dtq.com/yunmeng/zuotian.html 推荐查看天气:https://www.0dtq.com/yunmeng/7tian.html 推荐查看天气:https://www.0dtq.com/yunmeng/10tian.html 推荐查看天气:https://www.0dtq.com/yunmeng/15tian.html 推荐查看天气:https://www.0dtq.com/yunmeng/40tian.html 推荐查看天气:https://www.0dtq.com/anlu/ 推荐查看天气:https://www.0dtq.com/anlu/zuotian.html 推荐查看天气:https://www.0dtq.com/anlu/7tian.html 推荐查看天气:https://www.0dtq.com/anlu/10tian.html 推荐查看天气:https://www.0dtq.com/anlu/15tian.html 推荐查看天气:https://www.0dtq.com/anlu/40tian.html 推荐查看天气:https://www.0dtq.com/hanchuan/ 推荐查看天气:https://www.0dtq.com/hanchuan/zuotian.html 推荐查看天气:https://www.0dtq.com/hanchuan/7tian.html 推荐查看天气:https://www.0dtq.com/hanchuan/10tian.html 推荐查看天气:https://www.0dtq.com/hanchuan/15tian.html 推荐查看天气:https://www.0dtq.com/hanchuan/40tian.html 推荐查看天气:https://www.0dtq.com/jingzhou/ 推荐查看天气:https://www.0dtq.com/jingzhou/zuotian.html 推荐查看天气:https://www.0dtq.com/jingzhou/7tian.html 推荐查看天气:https://www.0dtq.com/jingzhou/10tian.html 推荐查看天气:https://www.0dtq.com/jingzhou/15tian.html 推荐查看天气:https://www.0dtq.com/jingzhou/40tian.html 推荐查看天气:https://www.0dtq.com/shashi/ 推荐查看天气:https://www.0dtq.com/shashi/zuotian.html 推荐查看天气:https://www.0dtq.com/shashi/7tian.html 推荐查看天气:https://www.0dtq.com/shashi/10tian.html 推荐查看天气:https://www.0dtq.com/shashi/15tian.html 推荐查看天气:https://www.0dtq.com/shashi/40tian.html 推荐查看天气:https://www.0dtq.com/gongan/ 推荐查看天气:https://www.0dtq.com/gongan/zuotian.html 推荐查看天气:https://www.0dtq.com/gongan/7tian.html 推荐查看天气:https://www.0dtq.com/gongan/10tian.html 推荐查看天气:https://www.0dtq.com/gongan/15tian.html 推荐查看天气:https://www.0dtq.com/gongan/40tian.html 推荐查看天气:https://www.0dtq.com/jianli/ 推荐查看天气:https://www.0dtq.com/jianli/zuotian.html 推荐查看天气:https://www.0dtq.com/jianli/7tian.html 推荐查看天气:https://www.0dtq.com/jianli/10tian.html 推荐查看天气:https://www.0dtq.com/jianli/15tian.html 推荐查看天气:https://www.0dtq.com/jianli/40tian.html 推荐查看天气:https://www.0dtq.com/jiangling/ 推荐查看天气:https://www.0dtq.com/jiangling/zuotian.html 推荐查看天气:https://www.0dtq.com/jiangling/7tian.html 推荐查看天气:https://www.0dtq.com/jiangling/10tian.html 推荐查看天气:https://www.0dtq.com/jiangling/15tian.html 推荐查看天气:https://www.0dtq.com/jiangling/40tian.html 推荐查看天气:https://www.0dtq.com/shishou/ 推荐查看天气:https://www.0dtq.com/shishou/zuotian.html 推荐查看天气:https://www.0dtq.com/shishou/7tian.html 推荐查看天气:https://www.0dtq.com/shishou/10tian.html 推荐查看天气:https://www.0dtq.com/shishou/15tian.html 推荐查看天气:https://www.0dtq.com/shishou/40tian.html 推荐查看天气:https://www.0dtq.com/honghu/ 推荐查看天气:https://www.0dtq.com/honghu/zuotian.html 推荐查看天气:https://www.0dtq.com/honghu/7tian.html 推荐查看天气:https://www.0dtq.com/honghu/10tian.html 推荐查看天气:https://www.0dtq.com/honghu/15tian.html 推荐查看天气:https://www.0dtq.com/honghu/40tian.html 推荐查看天气:https://www.0dtq.com/songzi/ 推荐查看天气:https://www.0dtq.com/songzi/zuotian.html 推荐查看天气:https://www.0dtq.com/songzi/7tian.html 推荐查看天气:https://www.0dtq.com/songzi/10tian.html 推荐查看天气:https://www.0dtq.com/songzi/15tian.html 推荐查看天气:https://www.0dtq.com/songzi/40tian.html 推荐查看天气:https://www.0dtq.com/huanggang/ 推荐查看天气:https://www.0dtq.com/huanggang/zuotian.html 推荐查看天气:https://www.0dtq.com/huanggang/7tian.html 推荐查看天气:https://www.0dtq.com/huanggang/10tian.html 推荐查看天气:https://www.0dtq.com/huanggang/15tian.html 推荐查看天气:https://www.0dtq.com/huanggang/40tian.html 推荐查看天气:https://www.0dtq.com/huangzhou/ 推荐查看天气:https://www.0dtq.com/huangzhou/zuotian.html 推荐查看天气:https://www.0dtq.com/huangzhou/7tian.html 推荐查看天气:https://www.0dtq.com/huangzhou/10tian.html 推荐查看天气:https://www.0dtq.com/huangzhou/15tian.html 推荐查看天气:https://www.0dtq.com/huangzhou/40tian.html 推荐查看天气:https://www.0dtq.com/tuanfeng/ 推荐查看天气:https://www.0dtq.com/tuanfeng/zuotian.html 推荐查看天气:https://www.0dtq.com/tuanfeng/7tian.html 推荐查看天气:https://www.0dtq.com/tuanfeng/10tian.html 推荐查看天气:https://www.0dtq.com/tuanfeng/15tian.html 推荐查看天气:https://www.0dtq.com/tuanfeng/40tian.html 推荐查看天气:https://www.0dtq.com/hongan/ 推荐查看天气:https://www.0dtq.com/hongan/zuotian.html 推荐查看天气:https://www.0dtq.com/hongan/7tian.html 推荐查看天气:https://www.0dtq.com/hongan/10tian.html 推荐查看天气:https://www.0dtq.com/hongan/15tian.html 推荐查看天气:https://www.0dtq.com/hongan/40tian.html 推荐查看天气:https://www.0dtq.com/luotian/ 推荐查看天气:https://www.0dtq.com/luotian/zuotian.html 推荐查看天气:https://www.0dtq.com/luotian/7tian.html 推荐查看天气:https://www.0dtq.com/luotian/10tian.html 推荐查看天气:https://www.0dtq.com/luotian/15tian.html 推荐查看天气:https://www.0dtq.com/luotian/40tian.html 推荐查看天气:https://www.0dtq.com/huanggangyingshan/ 推荐查看天气:https://www.0dtq.com/huanggangyingshan/zuotian.html 推荐查看天气:https://www.0dtq.com/huanggangyingshan/7tian.html 推荐查看天气:https://www.0dtq.com/huanggangyingshan/10tian.html 推荐查看天气:https://www.0dtq.com/huanggangyingshan/15tian.html 推荐查看天气:https://www.0dtq.com/huanggangyingshan/40tian.html 推荐查看天气:https://www.0dtq.com/huanggangxishui/ 推荐查看天气:https://www.0dtq.com/huanggangxishui/zuotian.html 推荐查看天气:https://www.0dtq.com/huanggangxishui/7tian.html 推荐查看天气:https://www.0dtq.com/huanggangxishui/10tian.html 推荐查看天气:https://www.0dtq.com/huanggangxishui/15tian.html 推荐查看天气:https://www.0dtq.com/huanggangxishui/40tian.html 推荐查看天气:https://www.0dtq.com/qinchun/ 推荐查看天气:https://www.0dtq.com/qinchun/zuotian.html 推荐查看天气:https://www.0dtq.com/qinchun/7tian.html 推荐查看天气:https://www.0dtq.com/qinchun/10tian.html 推荐查看天气:https://www.0dtq.com/qinchun/15tian.html 推荐查看天气:https://www.0dtq.com/qinchun/40tian.html 推荐查看天气:https://www.0dtq.com/huangmei/ 推荐查看天气:https://www.0dtq.com/huangmei/zuotian.html 推荐查看天气:https://www.0dtq.com/huangmei/7tian.html 推荐查看天气:https://www.0dtq.com/huangmei/10tian.html 推荐查看天气:https://www.0dtq.com/huangmei/15tian.html 推荐查看天气:https://www.0dtq.com/huangmei/40tian.html 推荐查看天气:https://www.0dtq.com/wuxue/ 推荐查看天气:https://www.0dtq.com/wuxue/zuotian.html 推荐查看天气:https://www.0dtq.com/wuxue/7tian.html 推荐查看天气:https://www.0dtq.com/wuxue/10tian.html 推荐查看天气:https://www.0dtq.com/wuxue/15tian.html 推荐查看天气:https://www.0dtq.com/wuxue/40tian.html 推荐查看天气:https://www.0dtq.com/xianning/ 推荐查看天气:https://www.0dtq.com/xianning/zuotian.html 推荐查看天气:https://www.0dtq.com/xianning/7tian.html 推荐查看天气:https://www.0dtq.com/xianning/10tian.html 推荐查看天气:https://www.0dtq.com/xianning/15tian.html 推荐查看天气:https://www.0dtq.com/xianning/40tian.html 推荐查看天气:https://www.0dtq.com/xianan/

优秀的个人博客,低调大师

JavaScript 中 requestAnimationFrame 在后台标签页不触发的问题排查与替代方案

做数据大屏或者定时轮询渲染的时候,很容易遇到一个现象:页面切到后台再切回来,某些依赖于 requestAnimationFrame 的动画或状态更新会「卡住」几秒,甚至像是什么都没发生。浏览器为了省电和降低 CPU,在标签页不可见时会暂停 requestAnimationFrame 的回调,把它降频甚至完全冻结。但业务里可能用它来驱动非纯视觉任务,比如轮询状态、计算布局、播放帧序列,这时候就出问题了。下面从一次实际排查过程说起,看看为什么会这样,以及除了切回页面强制刷新外,还有哪些更可控的写法。 ## 问题复现 假设有一个组件用 rAF 来做一个平滑的数字滚动,同时每帧检查一下远程任务是否完成。 ```js function startLoop() { let last = performance.now(); function frame(now) { const delta = now - last; if (delta > 16) { renderNumber(); checkTaskStatus(); last = now; } requestAnimationFrame(frame); } requestAnimationFrame(frame); } ``` 在浏览器里正常切换标签页后,`checkTaskStatus` 不会执行,等回来时又恢复正常。如果任务完成依赖这个轮询,用户切走再回来可能发现状态还停在旧数据上。 ## 为什么后台标签页没回调 规范里没有规定 rAF 在页面不可见时应该继续以 60fps 运行。实际情况是,大多数浏览器在文档进入 hidden 状态后,会把 rAF 回调挂起,或者降低到非常低的频率(比如 1fps 甚至 0)。因为 rAF 的本意是配合屏幕刷新,不可见的页面没有刷新需求,继续运行等于白白耗电。 可以用 `document.visibilityState` 验证: ```js let count = 0; function tick() { count++; console.log('frame', count, document.visibilityState); requestAnimationFrame(tick); } requestAnimationFrame(tick); ``` 在后台标签页停几秒再切回来,控制台里帧数几乎不增长。这不是 bug,是节能策略。 ## 如果只是做动画,应该怎么做 纯视觉动画在页面不可见时暂停是合理的,用户看不到,继续跑也没意义。如果希望切回来时从当前状态继续,而不是「时间跳变」,可以用时间戳计算差值,而不是依赖帧数累加。 ```js let startTime = null; function animate(now) { if (startTime === null) startTime = now; const elapsed = now - startTime; const progress = Math.min(elapsed / 1000, 1); element.style.transform = `translateX(${progress * 200}px)`; if (progress { checkTaskStatus(); }, 1000); } function stopPolling() { if (timer) clearInterval(timer); timer = null; } ``` 如果任务对时效性要求更高,可以在 `visibilitychange` 里做补偿:切回页面时立即执行一次。 ```js document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'visible') { checkTaskStatus(); } }); ``` ## 后台仍然需要执行的场景 有些逻辑必须持续运行,比如 WebSocket 心跳、音频处理、Web Worker 里的计算。这些不应该依赖主线程的 rAF。常见做法是把逻辑放进 Worker,Worker 的定时器不会被页面可见性冻结(但可能被浏览器整体节流策略影响,至少不受 visibility 直接控制)。 ```js // worker.js setInterval(() => { self.postMessage('heartbeat'); }, 5000); // main.js const worker = new Worker('worker.js'); worker.onmessage = (e) => { if (e.data === 'heartbeat') { sendHeartbeat(); } }; ``` WebSocket 心跳也可以直接用 `setInterval` 在页面里发,切后台时浏览器可能降低频率,但多数情况下不会完全停止。真正完全停止的情况出现在移动端切到桌面或锁屏,这时只能靠 Service Worker 或原生推送补足。 ## 兼容旧代码的折中处理 如果项目里已经大量使用了 rAF 做非视觉逻辑,全部重写成本高。可以在封装层加一个开关,在页面隐藏时改用 `setInterval` 兜底,可见时再切回 rAF。 ```js class FrameLoop { constructor(callback, fallbackInterval = 1000) { this.callback = callback; this.fallbackInterval = fallbackInterval; this.rafId = null; this.timer = null; this.onVisibilityChange = this.onVisibilityChange.bind(this); document.addEventListener('visibilitychange', this.onVisibilityChange); this.start(); } start() { this.stop(); if (document.visibilityState === 'visible') { const loop = () => { this.callback(); this.rafId = requestAnimationFrame(loop); }; this.rafId = requestAnimationFrame(loop); } else { this.timer = setInterval(() => this.callback(), this.fallbackInterval); } } stop() { if (this.rafId) cancelAnimationFrame(this.rafId); if (this.timer) clearInterval(this.timer); this.rafId = null; this.timer = null; } onVisibilityChange() { this.start(); } destroy() { this.stop(); document.removeEventListener('visibilitychange', this.onVisibilityChange); } } ``` 这样既保留了可见时的帧同步,又保证后台不会完全停止响应。回调里要注意不要做太重的事情,因为兜底间隔可能只有 1 秒,堆积起来反而更卡。 理解 rAF 的节能行为之后,选型就清晰了:画面相关用它,定时任务用定时器,必须后台运行的放 Worker。切页面的卡顿大多不是代码写错,而是把两种不同目的的东西混在了一起。 推荐查看天气:http://www.362tq.com/wangcang/zuotian.html 推荐查看天气:http://www.362tq.com/wangcang/7tian.html 推荐查看天气:http://www.362tq.com/wangcang/10tian.html 推荐查看天气:http://www.362tq.com/wangcang/15tian.html 推荐查看天气:http://www.362tq.com/wangcang/40tian.html 推荐查看天气:http://www.362tq.com/qingchuan/ 推荐查看天气:http://www.362tq.com/qingchuan/zuotian.html 推荐查看天气:http://www.362tq.com/qingchuan/7tian.html 推荐查看天气:http://www.362tq.com/qingchuan/10tian.html 推荐查看天气:http://www.362tq.com/qingchuan/15tian.html 推荐查看天气:http://www.362tq.com/qingchuan/40tian.html 推荐查看天气:http://www.362tq.com/jiange/ 推荐查看天气:http://www.362tq.com/jiange/zuotian.html 推荐查看天气:http://www.362tq.com/jiange/7tian.html 推荐查看天气:http://www.362tq.com/jiange/10tian.html 推荐查看天气:http://www.362tq.com/jiange/15tian.html 推荐查看天气:http://www.362tq.com/jiange/40tian.html 推荐查看天气:http://www.362tq.com/cangxi/ 推荐查看天气:http://www.362tq.com/cangxi/zuotian.html 推荐查看天气:http://www.362tq.com/cangxi/7tian.html 推荐查看天气:http://www.362tq.com/cangxi/10tian.html 推荐查看天气:http://www.362tq.com/cangxi/15tian.html 推荐查看天气:http://www.362tq.com/cangxi/40tian.html 推荐查看天气:http://www.362tq.com/suining/ 推荐查看天气:http://www.362tq.com/suining/zuotian.html 推荐查看天气:http://www.362tq.com/suining/7tian.html 推荐查看天气:http://www.362tq.com/suining/10tian.html 推荐查看天气:http://www.362tq.com/suining/15tian.html 推荐查看天气:http://www.362tq.com/suining/40tian.html 推荐查看天气:http://www.362tq.com/chuanshan/ 推荐查看天气:http://www.362tq.com/chuanshan/zuotian.html 推荐查看天气:http://www.362tq.com/chuanshan/7tian.html 推荐查看天气:http://www.362tq.com/chuanshan/10tian.html 推荐查看天气:http://www.362tq.com/chuanshan/15tian.html 推荐查看天气:http://www.362tq.com/chuanshan/40tian.html 推荐查看天气:http://www.362tq.com/anju/ 推荐查看天气:http://www.362tq.com/anju/zuotian.html 推荐查看天气:http://www.362tq.com/anju/7tian.html 推荐查看天气:http://www.362tq.com/anju/10tian.html 推荐查看天气:http://www.362tq.com/anju/15tian.html 推荐查看天气:http://www.362tq.com/anju/40tian.html 推荐查看天气:http://www.362tq.com/pengxi/ 推荐查看天气:http://www.362tq.com/pengxi/zuotian.html 推荐查看天气:http://www.362tq.com/pengxi/7tian.html 推荐查看天气:http://www.362tq.com/pengxi/10tian.html 推荐查看天气:http://www.362tq.com/pengxi/15tian.html 推荐查看天气:http://www.362tq.com/pengxi/40tian.html 推荐查看天气:http://www.362tq.com/shehong/ 推荐查看天气:http://www.362tq.com/shehong/zuotian.html 推荐查看天气:http://www.362tq.com/shehong/7tian.html 推荐查看天气:http://www.362tq.com/shehong/10tian.html 推荐查看天气:http://www.362tq.com/shehong/15tian.html 推荐查看天气:http://www.362tq.com/shehong/40tian.html 推荐查看天气:http://www.362tq.com/daying/ 推荐查看天气:http://www.362tq.com/daying/zuotian.html 推荐查看天气:http://www.362tq.com/daying/7tian.html 推荐查看天气:http://www.362tq.com/daying/10tian.html 推荐查看天气:http://www.362tq.com/daying/15tian.html 推荐查看天气:http://www.362tq.com/daying/40tian.html 推荐查看天气:http://www.362tq.com/neijiang/ 推荐查看天气:http://www.362tq.com/neijiang/zuotian.html 推荐查看天气:http://www.362tq.com/neijiang/7tian.html 推荐查看天气:http://www.362tq.com/neijiang/10tian.html 推荐查看天气:http://www.362tq.com/neijiang/15tian.html 推荐查看天气:http://www.362tq.com/neijiang/40tian.html 推荐查看天气:http://www.362tq.com/dongxing/ 推荐查看天气:http://www.362tq.com/dongxing/zuotian.html 推荐查看天气:http://www.362tq.com/dongxing/7tian.html 推荐查看天气:http://www.362tq.com/dongxing/10tian.html 推荐查看天气:http://www.362tq.com/dongxing/15tian.html 推荐查看天气:http://www.362tq.com/dongxing/40tian.html 推荐查看天气:http://www.362tq.com/najiangweiyuan/ 推荐查看天气:http://www.362tq.com/najiangweiyuan/zuotian.html 推荐查看天气:http://www.362tq.com/najiangweiyuan/7tian.html 推荐查看天气:http://www.362tq.com/najiangweiyuan/10tian.html 推荐查看天气:http://www.362tq.com/najiangweiyuan/15tian.html 推荐查看天气:http://www.362tq.com/najiangweiyuan/40tian.html 推荐查看天气:http://www.362tq.com/zizhong/ 推荐查看天气:http://www.362tq.com/zizhong/zuotian.html 推荐查看天气:http://www.362tq.com/zizhong/7tian.html 推荐查看天气:http://www.362tq.com/zizhong/10tian.html 推荐查看天气:http://www.362tq.com/zizhong/15tian.html 推荐查看天气:http://www.362tq.com/zizhong/40tian.html 推荐查看天气:http://www.362tq.com/longchang/ 推荐查看天气:http://www.362tq.com/longchang/zuotian.html 推荐查看天气:http://www.362tq.com/longchang/7tian.html 推荐查看天气:http://www.362tq.com/longchang/10tian.html 推荐查看天气:http://www.362tq.com/longchang/15tian.html 推荐查看天气:http://www.362tq.com/longchang/40tian.html 推荐查看天气:http://www.362tq.com/leshan/ 推荐查看天气:http://www.362tq.com/leshan/zuotian.html 推荐查看天气:http://www.362tq.com/leshan/7tian.html 推荐查看天气:http://www.362tq.com/leshan/10tian.html 推荐查看天气:http://www.362tq.com/leshan/15tian.html 推荐查看天气:http://www.362tq.com/leshan/40tian.html 推荐查看天气:http://www.362tq.com/shizhong/ 推荐查看天气:http://www.362tq.com/shizhong/zuotian.html 推荐查看天气:http://www.362tq.com/shizhong/7tian.html 推荐查看天气:http://www.362tq.com/shizhong/10tian.html 推荐查看天气:http://www.362tq.com/shizhong/15tian.html 推荐查看天气:http://www.362tq.com/shizhong/40tian.html 推荐查看天气:http://www.362tq.com/wutongqiao/ 推荐查看天气:http://www.362tq.com/wutongqiao/zuotian.html 推荐查看天气:http://www.362tq.com/wutongqiao/7tian.html 推荐查看天气:http://www.362tq.com/wutongqiao/10tian.html 推荐查看天气:http://www.362tq.com/wutongqiao/15tian.html 推荐查看天气:http://www.362tq.com/wutongqiao/40tian.html 推荐查看天气:http://www.362tq.com/jinkouhe/ 推荐查看天气:http://www.362tq.com/jinkouhe/zuotian.html 推荐查看天气:http://www.362tq.com/jinkouhe/7tian.html 推荐查看天气:http://www.362tq.com/jinkouhe/10tian.html 推荐查看天气:http://www.362tq.com/jinkouhe/15tian.html 推荐查看天气:http://www.362tq.com/jinkouhe/40tian.html 推荐查看天气:http://www.362tq.com/jianwei/ 推荐查看天气:http://www.362tq.com/jianwei/zuotian.html 推荐查看天气:http://www.362tq.com/jianwei/7tian.html 推荐查看天气:http://www.362tq.com/jianwei/10tian.html 推荐查看天气:http://www.362tq.com/jianwei/15tian.html 推荐查看天气:http://www.362tq.com/jianwei/40tian.html 推荐查看天气:http://www.362tq.com/jingyan/ 推荐查看天气:http://www.362tq.com/jingyan/zuotian.html 推荐查看天气:http://www.362tq.com/jingyan/7tian.html 推荐查看天气:http://www.362tq.com/jingyan/10tian.html 推荐查看天气:http://www.362tq.com/jingyan/15tian.html 推荐查看天气:http://www.362tq.com/jingyan/40tian.html 推荐查看天气:http://www.362tq.com/jiajiang/ 推荐查看天气:http://www.362tq.com/jiajiang/zuotian.html 推荐查看天气:http://www.362tq.com/jiajiang/7tian.html 推荐查看天气:http://www.362tq.com/jiajiang/10tian.html 推荐查看天气:http://www.362tq.com/jiajiang/15tian.html 推荐查看天气:http://www.362tq.com/jiajiang/40tian.html 推荐查看天气:http://www.362tq.com/muchuan/ 推荐查看天气:http://www.362tq.com/muchuan/zuotian.html 推荐查看天气:http://www.362tq.com/muchuan/7tian.html 推荐查看天气:http://www.362tq.com/muchuan/10tian.html 推荐查看天气:http://www.362tq.com/muchuan/15tian.html 推荐查看天气:http://www.362tq.com/muchuan/40tian.html 推荐查看天气:http://www.362tq.com/ebian/ 推荐查看天气:http://www.362tq.com/ebian/zuotian.html 推荐查看天气:http://www.362tq.com/ebian/7tian.html 推荐查看天气:http://www.362tq.com/ebian/10tian.html 推荐查看天气:http://www.362tq.com/ebian/15tian.html 推荐查看天气:http://www.362tq.com/ebian/40tian.html 推荐查看天气:http://www.362tq.com/mabian/ 推荐查看天气:http://www.362tq.com/mabian/zuotian.html 推荐查看天气:http://www.362tq.com/mabian/7tian.html 推荐查看天气:http://www.362tq.com/mabian/10tian.html 推荐查看天气:http://www.362tq.com/mabian/15tian.html 推荐查看天气:http://www.362tq.com/mabian/40tian.html 推荐查看天气:http://www.362tq.com/emeishan/ 推荐查看天气:http://www.362tq.com/emeishan/zuotian.html 推荐查看天气:http://www.362tq.com/emeishan/7tian.html 推荐查看天气:http://www.362tq.com/emeishan/10tian.html 推荐查看天气:http://www.362tq.com/emeishan/15tian.html 推荐查看天气:http://www.362tq.com/emeishan/40tian.html 推荐查看天气:http://www.362tq.com/nanchong/ 推荐查看天气:http://www.362tq.com/nanchong/zuotian.html 推荐查看天气:http://www.362tq.com/nanchong/7tian.html 推荐查看天气:http://www.362tq.com/nanchong/10tian.html 推荐查看天气:http://www.362tq.com/nanchong/15tian.html 推荐查看天气:http://www.362tq.com/nanchong/40tian.html 推荐查看天气:http://www.362tq.com/shunqing/ 推荐查看天气:http://www.362tq.com/shunqing/zuotian.html 推荐查看天气:http://www.362tq.com/shunqing/7tian.html 推荐查看天气:http://www.362tq.com/shunqing/10tian.html 推荐查看天气:http://www.362tq.com/shunqing/15tian.html 推荐查看天气:http://www.362tq.com/shunqing/40tian.html 推荐查看天气:http://www.362tq.com/jialing/ 推荐查看天气:http://www.362tq.com/jialing/zuotian.html 推荐查看天气:http://www.362tq.com/jialing/7tian.html 推荐查看天气:http://www.362tq.com/jialing/10tian.html 推荐查看天气:http://www.362tq.com/jialing/15tian.html 推荐查看天气:http://www.362tq.com/jialing/40tian.html 推荐查看天气:http://www.362tq.com/nanbu/ 推荐查看天气:http://www.362tq.com/nanbu/zuotian.html 推荐查看天气:http://www.362tq.com/nanbu/7tian.html 推荐查看天气:http://www.362tq.com/nanbu/10tian.html 推荐查看天气:http://www.362tq.com/nanbu/15tian.html 推荐查看天气:http://www.362tq.com/nanbu/40tian.html 推荐查看天气:http://www.362tq.com/yingshan/ 推荐查看天气:http://www.362tq.com/yingshan/zuotian.html 推荐查看天气:http://www.362tq.com/yingshan/7tian.html 推荐查看天气:http://www.362tq.com/yingshan/10tian.html 推荐查看天气:http://www.362tq.com/yingshan/15tian.html 推荐查看天气:http://www.362tq.com/yingshan/40tian.html 推荐查看天气:http://www.362tq.com/pengan/ 推荐查看天气:http://www.362tq.com/pengan/zuotian.html 推荐查看天气:http://www.362tq.com/pengan/7tian.html 推荐查看天气:http://www.362tq.com/pengan/10tian.html 推荐查看天气:http://www.362tq.com/pengan/15tian.html 推荐查看天气:http://www.362tq.com/pengan/40tian.html 推荐查看天气:http://www.362tq.com/yilong/ 推荐查看天气:http://www.362tq.com/yilong/zuotian.html 推荐查看天气:http://www.362tq.com/yilong/7tian.html 推荐查看天气:http://www.362tq.com/yilong/10tian.html 推荐查看天气:http://www.362tq.com/yilong/15tian.html 推荐查看天气:http://www.362tq.com/yilong/40tian.html 推荐查看天气:http://www.362tq.com/xichong/ 推荐查看天气:http://www.362tq.com/xichong/zuotian.html 推荐查看天气:http://www.362tq.com/xichong/7tian.html

优秀的个人博客,低调大师

JavaScript中关于this关键字的魔幻现实 一篇文章搞懂他

不得不承认JS中存在一些“历史的遗产”,比如基于全局变量的编程模型。 如果写一个函数,如: function test(name){ var namex = name console.log(this.namex) } test('jack') 方法调用之后,this.namex=undefined,为何呢?因为此处的this是全局对象window,这就令人比较头大。 不过别着急,慢慢往下看,关于this还有很多魔幻的现实,我们来一一解锁。 1、完整的函数调用 还是上面的代码,其实他的完整调用写法是这样的: function test(name){ var namex = name console.log(this.namex) } test.call(undefined, 'jack') test是一个函数对象--即Function对象,Function.prototype有call方法。call()会有两个参数,第一个参数是this上下文对象,第二个参数是函数入参列表。 如果call()传入的this上下文是undefined或null,那么window对象将成为默认的this上下文 2、对象中的this const obj = { name: 'Jack', greet: function() { console.log(this.name) } } obj.greet() //简写调用 obj.greet.call(obj) //完整调用 obj.greet()中的this无疑就是obj对象 3、对象方法中嵌套函数的this 对2中的代码进行修改: const obj = { name: 'Jack', greet: function() { retufn function(){console.log(this.name)} } } obj.greet()() //输出null 需要注意的是嵌套函数中的this依然是window,为什么呢?可以拆分来看: var greet = obj.greet() greet() // = greet.call(undefined) 嵌套函数被调用的时候,真实的调用者上下文是undefined,也就是window 4、原型与this function Clt() { } Clt.prototype.x = 10 Clt.prototype.test = function () { console.log(this) this.y = this.x + 1 } let bean = new Clt() bean.test(); console.log(bean.y) test方法中输出的this是一个Clt对象。 这里需要引入一个新的概念:构造器函数。 new关键字就是构造器函数,它的作用是: 一旦函数被new来调用,就会创建一个链接到该函数的prototype属性的新对象,同时this会被绑定到那个新对象上 理解了构造器函数,我们就理解了原型与this的关系了,因为new会重新指定this上下文 5、箭头函数与this ECMAScript6出现了箭头函数的用法,关于箭头函数中的this,需要先记住一句话: 函数体内的this对象,就是定义时所在的对象,而不是使用时所在的对象。 看代码(引自阮一峰老师的教程:https://es6.ruanyifeng.com/#docs/function#%E7%AE%AD%E5%A4%B4%E5%87%BD%E6%95%B0): function foo() { setTimeout(() => { console.log('id:', this.id); }, 100); } var id = 21; foo.call({ id: 42 }); // id: 42 此处的this指向了foo的this上下文,即定义时的this对象。 箭头函数与非箭头函数的this区别: function Timer() { this.s1 = 0; this.s2 = 0; // 箭头函数 setInterval(() => this.s1++, 1000); // 普通函数 setInterval(function () { this.s2++; }, 1000); } var timer = new Timer(); setTimeout(() => console.log('s1: ', timer.s1), 3100); setTimeout(() => console.log('s2: ', timer.s2), 3100); // s1: 3 // s2: 0 箭头函数的this指向了定义时所在对象的this;非箭头函数的this指向了运行时的作用域,即全局域window this的指向固定化,也算是解决了一些历史旧账,无疑带来的很大好处,比如封装调用: var handler = { id: '123456', init: function() { document.addEventListener('click', event => this.doSomething(event.type), false); }, doSomething: function(type) { console.log('Handling ' + type + ' for ' + this.id); } }; 一个嵌套的例子: function foo() { return () => { return () => { return () => { console.log('id:', this.id); }; }; }; } var f = foo.call({id: 1}); var t1 = f.call({id: 2})()(); // id: 1 var t2 = f().call({id: 3})(); // id: 1 var t3 = f()().call({id: 4}); // id: 1 最里层的this也绑定到了定义时所在对象的—即foo的this 总结 ECMAScript6的箭头函数也算是解决了一些历史问题。不过正如HTML5离不开HTML4一样,因为只有保持了继承与兼容,新技术的推广才会更加的迅速。 享受语言新特性之余,也要搞清楚旧版本的一些细节,这有助于更全面的掌握知识。 希望这篇文章对您有用!

优秀的个人博客,低调大师

通过阶乘的例子,练习在JavaScript, Scala和ABAP里实现尾递归(Tail Recursion)

Before we start to research tail recursion, let’s first have a look at the normal recursion. A simple factorial implementation by recursion: function factorial(n){ if(n ===1) { return 1; } return n *factorial(n -1); } Let N = 5, see how new stack frame is created for each time of recursive call: We have two stack frames now, one stores the context when n = 5, and the topmost one for current calculation: n = 4 Now since n equals to 1, we stop recursion. The current stack frame ( n = 1 ) will be poped up, the frame under it will be activated and become the topmost frame, with calculated result 1 passed into. key note for normal recursion: during recursion, every generated stack frame is needed and could not e destroyed until the final result is calculated. The calculation is actually not started until the recursion reaches the end ( the condition n === 1 fulfills ). If N is a big integer, it will lead to huge number of stack frames and finally the “stack overflow” or “out of memory” is inevitable. tail recursion Source code below: function tailFactorial(n, total) { if(n ===1) return total; return tailFactorial(n -1, n * total); } function factorial2(n) { return tailFactorial(n,1); } There are two biggest differences compared with normal recursion: (1) A new internal function tailFactorial is introduced here. (2) The calculation is actually now spread within every recursive stack frame. Each frame finishes one part of calculation and pass the current result to the next frame. Once the current stack frame finishes its task, it is actually not needed any more. And thus for example the model browser can then do some optimization on those useless stack frames. Observe the stack frame for tail recursion step by step: stack popped up: When N = 20, the tail recursion has a far better performance than the normal recursion: Update 2016-01-11 Tail recursion implementation via Scala: The interesting thing is, after the Scala code is compiled into Java Byte code, compiler will eliminate the recursion automatically: Tail Recursion in ABAP First this is the normal recursion: REPORT zrecursion. START-OF-SELECTION. DATA: lv_result TYPE int4. PERFORM fac USING 6 CHANGING lv_result. WRITE: / lv_result. FORM fac USING iv_n TYPE int4 CHANGING cv_result TYPE int4. DATA: lv_n TYPE i. cv_result = lv_n = iv_n. lv_n = lv_n - 1. IF lv_n > 1. PERFORM fac USING lv_n CHANGING cv_result. ENDIF. IF lv_n = 1. cv_result = cv_result * lv_n. ELSE. cv_result = cv_result * iv_n. ENDIF. ENDFORM. And here comes tail recursion version: REPORT ztail. START-OF-SELECTION. DATA: lv_result TYPE int4. PERFORM fac USING 5 1 CHANGING lv_result. WRITE: / lv_result. FORM fac USING iv_n TYPE int4 iv_acc TYPE int4 CHANGING cv_result TYPE int4. DATA: lv_n TYPE i, lv_accumulate TYPE i. IF iv_n < 1. cv_result = 1. ELSEIF iv_n = 1. cv_result = iv_acc * iv_n. ELSEIF iv_n > 1. lv_n = iv_n - 1. lv_accumulate = iv_acc * iv_n. PERFORM fac USING lv_n lv_accumulate CHANGING cv_result. ENDIF. ENDFORM. 本文来自云栖社区合作伙伴“汪子熙”,了解相关信息可以关注微信公众号"汪子熙"。

优秀的个人博客,低调大师

JavaScript ES6 Fetch API时需要注意的一个Cookie问题

When I am doing a test of comparison between Stateful and Stateless BSP application ( mentioned in blog Stateless and Stateful – Different behavior in application side ), I meet with a strange issue. The conclusion is stateful BSP application will handle request sequentially. Suppose in client I send two request A and B to server. Request A takes 3 seconds to finish and B 2 seconds. The request is sent via jQuery API.It means for stateful application, I will observe the following timeline in Chrome network tab: (1) the start time of both request are almost the same, since I send out two request in client code almost at the same time.(2) even though the second request itself takes 2 seconds to finish, the total processing time for it is 3 seconds waiting for A to finish first + 2 seconds = 5 seconds in the end. The above test did verify the conclusion.However when I change the approach to send request into ES6 fetch API, <%@page language="abap" %> <%@extension name="htmlb" prefix="htmlb" %> <!DOCTYPE html> <html> <head> <title>Jerry Test Stateful</title> </head> <body> <button onclick="fire()">Fire two request</button> <script> function wrapperOnFetch(url){ fetch(url).then(function(response){ return response.json(); }).then(function(json){ console.log(url + ":" + json.message); }); } function fire(){ wrapperOnFetch("first.json"); wrapperOnFetch("second.json"); } </script> </body> </html> the testing request for stateful application looks as below this time: The two requests are handled simultaneously ( request B only takes 2 seconds to finish, no 3 seconds’ wait time for A to finish this time ), the response of second request returns first before the first, which could be observed in console: why the latest ES6 API causes such discrepancy with known conclusion?Just compare the cookie of requests sent via these two kinds of API: Through comparison I get to know that the session cookiesap-contextid is not sent together with request triggered by ES6 Fetch API.Then in Fetch documentation I find out that I need to add option credentials: “include”. function wrapperOnFetch(url){ // enable session cookie sent with request fetch(url,{ credentials:"include" }).then(function(response){ return response.json(); }).then(function(json){ console.log(url + ":" + json.message); }); } After this change the stateful BSP application behaves as expected: the requests are handled in sequence. 本文来自云栖社区合作伙伴“汪子熙”,了解相关信息可以关注微信公众号"汪子熙"。

优秀的个人博客,低调大师

【CDN云课堂】技术专家直播分享:如何在CDN边缘节点执行你的JavaScript?

Serverless和边缘计算都是目前云计算领域备受瞩目的研究和应用方向。做为拥有超过130Tbps带宽分发能力的阿里云CDN,巨大的边缘网络有超过2800个节点遍布全球,如何将中心源站的计算能力下沉到边缘节点,进一步降低客户端访问延时进而提升用户体验,一直是阿里云CDN投入重点研究的方向。 阿里云CDN将Serverless和边缘计算的优势相融合,推出边缘轻量编程环境—EdgeRoutine,4月27日(周一)晚19:00,阿里云CDN技术专家将带来一场线上直播,分享阿里云CDN边缘轻量编程环境-EdgeRoutine的原理、使用场景和实践案例,欢迎大家点击报名观看。 直播介绍 直播主题:CDN边缘轻量编程环境—EdgeRoutine发布直播时间:4月27日(周一)晚19:00直播讲师:阿里云技术专家 洪晓龙直播内容:分享阿里云CDN

优秀的个人博客,低调大师

Javascript前端开发:阿里JS面试题让你深入了解原型与继承

题目如下: var F = function(){} Object.prototype.a = function(){ console.log('a()') } Function.prototype.b = function(){ console.log('b()') } var f = new F() F.a() F.b() f.a() f.b() 主要考查的技术点: 1.、原型与原型链 2、实例对象、构造函数、Object、 Function的关系 分析: F是个构造函数,而f是构造函数F的一个实例。 因为F instanceof Object == true、F instanceof Function == true 由此我们可以得出结论:F是Object 和 Function两个的实例,即F既能访问到a,也能访问到b。 所以F.a() 输出 a() F.b() 输出 b() 对于f,我们先来看下下面的结果: f并不是Function的实例,因为它本来就不是构造函数,所以就调用Function原型链上的相关属性和方法了,只能访问Object原型链。 所以f.a() 输出 a() 而f.b()就报错了。 接下来,我们具体分析下,它们是如何按路径查找的: f.a的查找路径: f自身: 没有 ---> f.__proto__(Object.prototype): 输出a() f.b的查找路径: f自身: 没有 ---> f.__proto__(Object.prototype): 没有 ---> f.__proto__.__proto__ (Object.prototype.__proto__): 因为找不到,所以报错 F.a的查找路径: F自身: 没有 ---> F.__proto__(Function.prototype): 没有 ---> F.__proto__.__proto__(Object.prototype): 输出 a() F.b的查找路径: F自身: 没有 ---> F.__proto__(Function.prototype): b()

资源下载

更多资源
Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册