08 2024 档案

摘要:<style> dt { position: sticky; top: 0; } </style> <body> <dl> <dt>A</dt> <dd>Adrew W.K</dd> <dd>Adapter</dd> <dt>B</dt> <dd>Border</dd> <dd>Beef</dd> 阅读全文
posted @ 2024-08-29 15:17 Zhentiw 阅读(2) 评论(0) 推荐(0) 编辑
摘要:In this post, we’ll explore an intriguing use of JavaScript’s Proxy and Symbol.toPrimitive to perform cumulative operations, mimicking a numeric conte 阅读全文
posted @ 2024-08-28 02:16 Zhentiw 阅读(13) 评论(0) 推荐(0) 编辑
摘要:$breakpoints: ( 'phone': (320px, 480px), 'pad': (481px, 768px), 'notebook': (769px, 1024px), 'desktop': (1025px, 1200px), 'tv': 1201px, ) @mixin respo 阅读全文
posted @ 2024-08-26 23:49 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:// Object.prototype[Symbol.iterator] = function() { // return Object.values(this)[Symbol.iterator](); // } Object.prototype[Symbol.iterator] = functio 阅读全文
posted @ 2024-08-26 00:20 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:Normal browser has restiction that doesn't allow you automaticlly play the video, unless your site has high Media Enagement index (MEI). There are 2 w 阅读全文
posted @ 2024-08-25 20:02 Zhentiw 阅读(13) 评论(0) 推荐(0) 编辑
摘要:One way data binding, the parent component pasing data through v-modelto child component, if child modify the data, v-modelwill take care emit the cha 阅读全文
posted @ 2024-08-25 19:51 Zhentiw 阅读(62) 评论(0) 推荐(0) 编辑
摘要:/** * Big integer sum * Using strings to represent big integers * @param {string} a * @param {string} b * @returns {string} */ function bigIntSum(a, b 阅读全文
posted @ 2024-08-25 16:05 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:When you use ChatGPT, the response comes in stream, so that it can appears on screen whenever data come back from server, we don't need to wait all da 阅读全文
posted @ 2024-08-25 15:49 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:Try option 1: Promise Promise running in Microtask queue, and rendering should wait until the queue is empty; If you have a large number of time-consu 阅读全文
posted @ 2024-08-24 16:40 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:const fetch = () => new Promise((res) => { setTimeout(() => res({ user: 'zhen' }), 1150) }) globalThis.fetch = fetch async function getUser() { return 阅读全文
posted @ 2024-08-23 19:43 Zhentiw 阅读(10) 评论(0) 推荐(0) 编辑
摘要:For this code, try to not modify the code itself but mutate obj var o = (function () { var obj = { a: 1, b: 2, }; return { get: function (k) { return 阅读全文
posted @ 2024-08-23 03:47 Zhentiw 阅读(10) 评论(0) 推荐(0) 编辑
摘要:The basic interpolatefunction we can create: function interpolate(str, params) { let names = Object.keys(params); // ["title", "description"] let valu 阅读全文
posted @ 2024-08-20 14:49 Zhentiw 阅读(11) 评论(0) 推荐(0) 编辑
摘要:/* View Transitions */ /* STEP 1 */ ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 1s; } /* STEP 2 */ @keyframes fade- 阅读全文
posted @ 2024-08-20 14:29 Zhentiw 阅读(37) 评论(0) 推荐(0) 编辑
摘要:Let's say we have a web component: import { getProductById } from "../services/Menu.js"; import { addToCart } from "../services/Order.js"; export defa 阅读全文
posted @ 2024-08-20 14:23 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:// memento.js import { TodoList } from "./classes.js"; export const TodoHistory = { history: [], push(state) { if (state) { // always push a new Set t 阅读全文
posted @ 2024-08-19 14:45 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:Refer to: https://stately.ai/docs/actor-model What defines an “actor”?​ Actors are independent “live” objects that can communicate with each other via 阅读全文
posted @ 2024-08-14 15:07 Zhentiw 阅读(10) 评论(0) 推荐(0) 编辑
摘要:Problem to Solve Reparesent a value that is immutable and distinct from other objects based on its properties rather than its identity. Solution Creat 阅读全文
posted @ 2024-08-14 14:52 Zhentiw 阅读(1) 评论(0) 推荐(0) 编辑
摘要:Problem to Solve Share functionality between classes without using inheritance. Solution Create a class containing methods that can be used by other c 阅读全文
posted @ 2024-08-14 14:48 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:One of the interesting things about verbatimModuleSyntax in TypeScript is that it requires a specific type of import when you're working with types. L 阅读全文
posted @ 2024-08-13 01:29 Zhentiw 阅读(64) 评论(0) 推荐(0) 编辑
摘要:To fix the CommonJS export issue, we need to make a change to our tsconfig.json file. Add the verbatimModuleSyntax setting and set it to true: { "comp 阅读全文
posted @ 2024-08-13 01:24 Zhentiw 阅读(63) 评论(0) 推荐(0) 编辑
摘要:The module and moduleResolution options in the tsconfig.json file can be confusing. Here we'll discuss the differences between the module and moduleRe 阅读全文
posted @ 2024-08-13 01:17 Zhentiw 阅读(24) 评论(0) 推荐(0) 编辑
摘要:class ApplicationError extends Error { get name() { return this.constructor.name; } } class DatabaseError extends ApplicationError {} class UserFacing 阅读全文
posted @ 2024-08-11 22:06 Zhentiw 阅读(2) 评论(0) 推荐(0) 编辑
摘要:You can create a javascript file as a bash file: #!/usr/bin/env node console.log("Hello World!") Run the script: ./script.js 阅读全文
posted @ 2024-08-11 22:04 Zhentiw 阅读(6) 评论(0) 推荐(0) 编辑
摘要:class Product { name; price; constructor(name, price) { this.name = name; try { this.price = price * 1.30; } catch(e) { throw new Error("Product canno 阅读全文
posted @ 2024-08-11 22:03 Zhentiw 阅读(2) 评论(0) 推荐(0) 编辑
摘要:Here we're attempting to import several PNG files into our TypeScript program: import pngUrl1 from "./example1.png"; // red squiggly line under "./exa 阅读全文
posted @ 2024-08-08 19:20 Zhentiw 阅读(6) 评论(0) 推荐(0) 编辑
摘要:Here we're importing a function myModuleFunc from my-module: import { myModuleFunc } from "my-module"; // red squiggly line under "my-module" Let's st 阅读全文
posted @ 2024-08-08 19:17 Zhentiw 阅读(13) 评论(0) 推荐(0) 编辑
摘要:In tsconfig file, you have targetand libsconfiguration. You always need to define a target, recommended as es2022 Specifying the lib option also lets 阅读全文
posted @ 2024-08-08 19:01 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:Docs: https://webkit.org/blog/6240/ecmascript-6-proper-tail-calls-in-webkit/ /* This is a recursive function without PTC */ function fatorial(n) { if 阅读全文
posted @ 2024-08-07 19:29 Zhentiw 阅读(3) 评论(0) 推荐(0) 编辑
摘要:The declare keyword in TypeScript allows you to specify types for global variables. Whenever you use it, an ambient context is created, which means th 阅读全文
posted @ 2024-08-07 19:13 Zhentiw 阅读(2) 评论(0) 推荐(0) 编辑
摘要:Typescript check a file whether it contains any export/import, if it is, then it's a module; if not then it's a script. What's the difference between  阅读全文
posted @ 2024-08-07 19:04 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:/** * How do we annotate the errors this function throws? */ type PossibleErrors = SyntaxError | DOMException; const getUserFromLocalStorage = (id: st 阅读全文
posted @ 2024-08-07 18:58 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:For the following code: const objOfFunctions = { string: (input: string) => input.toUpperCase(), number: (input: number) => input.toFixed(2), boolean: 阅读全文
posted @ 2024-08-07 17:53 Zhentiw 阅读(6) 评论(0) 推荐(0) 编辑
摘要:import { expect, it, vitest } from 'vitest'; const logId = (obj: { id: string }) => { console.log(obj.id); }; const logName = (obj: { name: string }) 阅读全文
posted @ 2024-08-06 19:56 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:Make those pass: import { Equal, Expect } from "@total-typescript/helpers"; type Event = "click" | "hover" | "scroll"; type CallbackType = unknown; co 阅读全文
posted @ 2024-08-06 15:13 Zhentiw 阅读(6) 评论(0) 推荐(0) 编辑
摘要:max-content https://developer.mozilla.org/en-US/docs/Web/CSS/max-content The max-content sizing keyword represents the maximum intrinsic size of the c 阅读全文
posted @ 2024-08-02 15:23 Zhentiw 阅读(8) 评论(0) 推荐(0) 编辑
摘要:function pipe<A, B>(fn: (a: A) => B) { function run(a: A) { return fn(a) } run.pipe = <C, >(fn2: (b: B) => C) => pipe((a: A) => fn2(fn(a))) return run 阅读全文
posted @ 2024-08-02 14:51 Zhentiw 阅读(8) 评论(0) 推荐(0) 编辑
摘要:type BaseTable = { [colName: string]: string | number | boolean; } type Columns<Tables extends { [tableName: string]: BaseTable }> = { [K in keyof Tab 阅读全文
posted @ 2024-08-02 14:50 Zhentiw 阅读(3) 评论(0) 推荐(0) 编辑
摘要:class QueryBuilder { private fields: string[] = [] private wheres: Record<string, string> = {} private table: string = "" select(...columns: string[]) 阅读全文
posted @ 2024-08-02 14:19 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:import { expect, it, vitest } from 'vitest'; interface User { id: number; name: string; } function printUser(user: User) { Object.keys(user).forEach(( 阅读全文
posted @ 2024-08-01 15:12 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:interface User { id: number; name: string; } const users = [ { name: 'Waqas', }, { name: 'Zain', }, ]; const usersWithIds: User[] = users.map((user, i 阅读全文
posted @ 2024-08-01 14:46 Zhentiw 阅读(10) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示