随笔分类 -  Javascript

上一页 1 2 3 4 5 6 ··· 30 下一页
摘要: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 阅读(3) 评论(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 阅读(3) 评论(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 阅读(9) 评论(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 阅读(3) 评论(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 阅读(10) 评论(0) 推荐(0) 编辑
摘要:// loop function demo1() { // before loop beforeLoopCode; for (initCode; conditionCode; stepChangeCode) { loopCode } postCode } // recursive function 阅读全文
posted @ 2024-10-22 14:51 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:class MemoizeMap { constructor() { this._map = new Map(); this._weakMap = new WeakMap(); } _isObject(v) { return typeof v "object" && v !== null; } se 阅读全文
posted @ 2024-10-21 14:33 Zhentiw 阅读(2) 评论(0) 推荐(0) 编辑
摘要:Promise.myAll = function (promises) { let res, rej; const p = new Promise((resolve, reject) => { res = resolve; rej = reject; }); let i = 0; let resul 阅读全文
posted @ 2024-10-18 14:54 Zhentiw 阅读(3) 评论(0) 推荐(0) 编辑
摘要:Function.apply.myCall = function (ctx, ...args) { ctx = ctx null || ctx undefined ? globalThis : Object(ctx); const fn = this; const key = Sybmol("fn" 阅读全文
posted @ 2024-10-18 14:40 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:For Javascript Object, you cannot assume the order of Object property the same as the order of adding those property. The actual order follow this rul 阅读全文
posted @ 2024-10-14 15:01 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:Proxy The Proxy object enables you to create a proxy for another object, which can intercept and redefine fundamental operations for that object. So w 阅读全文
posted @ 2024-10-10 15:16 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:[] + [] Answer: "" Both arrays ([]) are first converted to their string representations before the + operator is applied. In JavaScript, arrays are co 阅读全文
posted @ 2024-10-10 14:47 Zhentiw 阅读(3) 评论(0) 推荐(0) 编辑
摘要:const obj = { a: 1, b: 2, c: { d: 1, e: 2, }, }; function isObject(val) { return val !== null && typeof val "object"; } function observe(obj) { const 阅读全文
posted @ 2024-10-09 15:07 Zhentiw 阅读(2) 评论(0) 推荐(0) 编辑
摘要:const obj = { a: 1, b: 2, c: { a: 1, b: 2, }, }; function isObject(val) { return val !== null && typeof val "object"; } function observe(obj) { for (l 阅读全文
posted @ 2024-10-09 14:58 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:As we know we can read property value from an object as so: const obj = {} obj.xxxx; obj[xxxx]; So what's the difference between those two? obj.x ECMA 阅读全文
posted @ 2024-10-08 15:09 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:Function.prototype.myBind = function (ctx, ...args) { const fn = this; return function (...subArgs) { console.log(new.target); const allArgs = [...arg 阅读全文
posted @ 2024-10-08 14:52 Zhentiw 阅读(8) 评论(0) 推荐(0) 编辑
摘要:The new.target meta-property lets you detect whether a function or constructor was called using the new operator. In constructors and functions invoke 阅读全文
posted @ 2024-10-08 14:50 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:Eliminate the ambiguity of the function What ambiguity means? Normally a function can do two things 1. Instruction sequence 2. Contruction function a( 阅读全文
posted @ 2024-10-06 00:35 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:async function asy1() { console.log(1) await asy2() console.log(2) } asy2 = async () => { // First set // await setTimeout((_) => { // Promise.resolve 阅读全文
posted @ 2024-10-06 00:17 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:We often see circular dependency, why it's a problem, why we should avoid it and hwo to avoid it? Let's see any example first // main.js import A from 阅读全文
posted @ 2024-10-05 20:16 Zhentiw 阅读(13) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 ··· 30 下一页
点击右上角即可分享
微信分享提示