10 2024 档案
摘要:Using the Node.js glob function as a practical example, you'll learn how Array.fromAsync facilitates the creation of arrays from asynchronous iterable
阅读全文
摘要:Let's say for the laptop, default node version is 20.17.0, if you want the project to use 20.18.0with pnpm, you can do // use node 20.18.0 pnpm env us
阅读全文
摘要:import {computed} from "vue" export function useComputed(fn) { const map = new Map() return function(...args) { const key = JSON.stringify(args); if (
阅读全文
摘要:// loop function demo1() { // before loop beforeLoopCode; for (initCode; conditionCode; stepChangeCode) { loopCode } postCode } // recursive function
阅读全文
摘要:class MemoizeMap { constructor() { this._map = new Map(); this._weakMap = new WeakMap(); } _isObject(v) { return typeof v "object" && v !== null; } se
阅读全文
摘要:Promise.myAll = function (promises) { let res, rej; const p = new Promise((resolve, reject) => { res = resolve; rej = reject; }); let i = 0; let resul
阅读全文
摘要:Function.apply.myCall = function (ctx, ...args) { ctx = ctx null || ctx undefined ? globalThis : Object(ctx); const fn = this; const key = Sybmol("fn"
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:[] + [] Answer: "" Both arrays ([]) are first converted to their string representations before the + operator is applied. In JavaScript, arrays are co
阅读全文
摘要:const obj = { a: 1, b: 2, c: { d: 1, e: 2, }, }; function isObject(val) { return val !== null && typeof val "object"; } function observe(obj) { const
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:Function.prototype.myBind = function (ctx, ...args) { const fn = this; return function (...subArgs) { console.log(new.target); const allArgs = [...arg
阅读全文
摘要:The new.target meta-property lets you detect whether a function or constructor was called using the new operator. In constructors and functions invoke
阅读全文
摘要:<template> <div> count: {{ count }} </div> <div> doubled: {{ doubledCount }} </div> <button @click="increase">increase</button> </template> <script se
阅读全文
摘要:how to encapsulate second time of ui components For example we have follow code, with one UI component MyInput // App.vue <template> <div> <MyInput></
阅读全文
摘要:Eliminate the ambiguity of the function What ambiguity means? Normally a function can do two things 1. Instruction sequence 2. Contruction function a(
阅读全文
摘要:async function asy1() { console.log(1) await asy2() console.log(2) } asy2 = async () => { // First set // await setTimeout((_) => { // Promise.resolve
阅读全文
摘要: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
阅读全文
摘要:<!doctype html> <html lang="en"> <head> <meta charset="utf-8"/> <title>CSS avatar scale</title> <style> .avatar { width: 150px; height: 150px; backgro
阅读全文