随笔分类 -  Javascript

上一页 1 2 3 4 5 6 ··· 30 下一页
摘要:var a = { n: 1 }; var b = a; a.x = a = { n: 2 }; console.log(a.x); // undefined console.log(b.x); // {n: 2} Javascript see the following code, mainly 阅读全文
posted @ 2024-12-09 15:17 Zhentiw 阅读(13) 评论(0) 推荐(0)
摘要:Write big number // NOT 100000 // Better 100_000 1e5 Shorthands syntax for floating number // Normal 0.123 // The same .123 // eX also apply to floati 阅读全文
posted @ 2024-12-03 16:59 Zhentiw 阅读(10) 评论(0) 推荐(0)
摘要:Example 1 Before function addEvent(ele, eventName, handler) { if (ele.addEventListener) { ele.addEventListener(eventName, handler); } else if (ele.att 阅读全文
posted @ 2024-12-03 03:33 Zhentiw 阅读(17) 评论(0) 推荐(0)
摘要:let _globalThis: any export const getGlobalThis = (): any => { return ( _globalThis || (_globalThis = typeof globalThis !== 'undefined' ? globalThis : 阅读全文
posted @ 2024-12-02 15:05 Zhentiw 阅读(10) 评论(0) 推荐(0)
摘要:== 从上到下按照规则比较,直到能够得到确切结果为止:1. 两端存在 NaN,返回 false2. undefined 和 null 只有与自身比较,或者互相比较时,才会返回 true,和其他原始类型比较返回 false3. 两端类型相同,比较值4. 两端都是原始类型,转换成数字重新比较 5. 一端 阅读全文
posted @ 2024-11-29 15:32 Zhentiw 阅读(17) 评论(0) 推荐(0)
摘要:U+200B: Zero-width space Used for soft line breaks in long words. U+FEFF: Zero-width non-breaking space Prevents line breaks at specific positions. U+ 阅读全文
posted @ 2024-11-28 01:09 Zhentiw 阅读(37) 评论(0) 推荐(0)
摘要:Virtual DOM Advantage: One of the advantages of the virtual DOM is cross-platform rendering abstraction. The virtual DOM can connect to different host 阅读全文
posted @ 2024-11-26 21:03 Zhentiw 阅读(29) 评论(0) 推荐(0)
摘要:When you run node.js you can run node --expose-gc index.js Which will allow you manully cleanup gc: global.gc() Map For map, it is easy to cost memory 阅读全文
posted @ 2024-11-26 20:41 Zhentiw 阅读(27) 评论(0) 推荐(0)
摘要:For example you have nested for loop, and from inner most for loop you want to break not just inner loop but also outmost for loop how to do that? We 阅读全文
posted @ 2024-11-26 20:25 Zhentiw 阅读(12) 评论(0) 推荐(0)
摘要:We have a module: const key = Symbol('key') export class A { [key] = 1 value () { console.log(this[key]) } } It seems that keyis not expose to outside 阅读全文
posted @ 2024-11-25 21:10 Zhentiw 阅读(12) 评论(0) 推荐(0)
摘要:function main() { const datas = new Array(10000).fill(null).map((_, i) => i) function taskHanlder(_, i) { console.log(i) } performChunkNode(datas, tas 阅读全文
posted @ 2024-11-25 20:51 Zhentiw 阅读(11) 评论(0) 推荐(0)
摘要:When attempting to load the same module twice in JavaScript you'll hit a cache and code won't re-run. In scenarios where you actually do want to have 阅读全文
posted @ 2024-11-25 15:25 Zhentiw 阅读(19) 评论(0) 推荐(0)
摘要:During the past, this was a working solution function isArray(obj) { return Object.prototype.toString.call(obj) '[object Array]' } But now it doesn't 阅读全文
posted @ 2024-11-24 20:26 Zhentiw 阅读(15) 评论(0) 推荐(0)
摘要:What's the output of following code: let a = 1; const b = a + ++a * a++; In Javascript, the code always run from lef to right. Both ++aand a++ are exp 阅读全文
posted @ 2024-11-24 19:29 Zhentiw 阅读(8) 评论(0) 推荐(0)
摘要:Why? Mainly due to undefinedis not a keyword, therefore you are able to create a variable called undefinedand assign it any value let undefined = 10 A 阅读全文
posted @ 2024-11-24 19:23 Zhentiw 阅读(10) 评论(0) 推荐(0)
摘要:It is not good to import axios from each Components or different services, because it will create a new instance of axios everytime. import axios from 阅读全文
posted @ 2024-11-24 03:49 Zhentiw 阅读(8) 评论(0) 推荐(0)
摘要:Main difference is that in keyword will check on object prototype chain as well but hasOwnProperty won't check agaist prototype chain const obj = {} ' 阅读全文
posted @ 2024-11-23 22:45 Zhentiw 阅读(7) 评论(0) 推荐(0)
摘要:Let's see the following code function copyText(text) { if (navigator.clipboard) { navigator.clipboard.writeText(text); } else { const input = document 阅读全文
posted @ 2024-11-23 22:41 Zhentiw 阅读(20) 评论(0) 推荐(0)
摘要:The Reflect namespace object contains static methods for invoking interceptable JavaScript object internal methods. The methods are the same as those 阅读全文
posted @ 2024-11-17 03:04 Zhentiw 阅读(12) 评论(0) 推荐(0)
摘要:const [a, b] = { a: 3, b: 4, }; console.log(a, b); // TypeError: {(intermediate value)(intermediate value)} is not iterable How to make it work withou 阅读全文
posted @ 2024-11-06 15:53 Zhentiw 阅读(25) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 ··· 30 下一页