摘要: const reg = /^[0-9]+/g reg.test('123') // expect true actual true reg.test('123') // expect true actual false reg.test('123') // expect true actual tr 阅读全文
posted @ 2023-12-28 15:48 Laggage 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 值类型和引用类型 原始类型(alias: 值类型,基础类型) primitive: string number boolean undefined symbol null 引用类型: Object 其他内置Object派送类型 Array Function Map Set WeakMap WeakS 阅读全文
posted @ 2023-04-23 23:05 Laggage 阅读(32) 评论(0) 推荐(0) 编辑
摘要: "种草" kubernetes-dashboard 安装部署dashboard 创建用于登录面板的ServiceAccount 权限控制 "种草" kubernetes-dashboard Kubernetes Dashboard 是通用的用于管理 Kubernetes 集群的 WebUI面板 ku 阅读全文
posted @ 2023-04-19 23:19 Laggage 阅读(278) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 给定一个字符串数组, 实现它的全排列组合. English Given an array of strings, do Permutation & Combination. It's also useful for the prop types like video controlsLi 阅读全文
posted @ 2022-12-18 18:55 Laggage 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 有时我们需要限制数字的范围... 示例: type result = NumberRange<2 , 9> // | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 English Sometimes we want to limit the range of numbers 阅读全文
posted @ 2022-12-04 19:53 Laggage 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 构造一个给定长度的元组。 例如 type result = ConstructTuple<2> // 期望得到 [unknown, unkonwn] English Construct a tuple with a given length. For example type resul 阅读全文
posted @ 2022-12-04 19:50 Laggage 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 实现 MapTypes<T, R>, 它将对象 T 中的类型转换为有如下结构的类型 R 定义的类型 type StringToNumber = { mapFrom: string; // 类型为 string 的键(key) mapTo: number; // 会被转换为 number 阅读全文
posted @ 2022-11-14 21:27 Laggage 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 实现类型的 Lodash.uniq, Unique 接受数组 T, 返回没有重复值的数组 T English Implement the type version of Lodash.uniq, Unique takes an Array T, returns the Array T w 阅读全文
posted @ 2022-11-12 03:03 Laggage 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 实现类型的 Array.lastIndexOf, LastIndexOf<T, U> 接受泛型参数 Array T 和 any U 并返回数组 T 中最后一个 U 的索引 示例: type Res1 = LastIndexOf<[1, 2, 3, 2, 1], 2>; // 3 type 阅读全文
posted @ 2022-11-12 01:44 Laggage 阅读(65) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 实现类型版本的 Array.join, Join<T, U> 接受数组 T 和 string 或者 number 类型 U 作为泛型参数, 并返回 U 连接数组 T 后的字符串. English Implement the type version of Array.join, Join 阅读全文
posted @ 2022-11-08 01:41 Laggage 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 实现类型版本的 Array.indexOf, indexOf<T, U> 接受一个数组T和any类型的U作为参数, 返回T中第一个U的索引 type Res = IndexOf<[1, 2, 3], 2>; // expected to be 1 type Res1 = IndexOf< 阅读全文
posted @ 2022-10-25 01:43 Laggage 阅读(47) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 实现类型版本的 Math.trunc, 其接受一个字符串或数字作为泛型参数, 并返回移除了全部小数位部分后的整数 示例: type A = Trunc<12.34>; // 12 English Implement the type version of Math.trunc, whic 阅读全文
posted @ 2022-10-24 23:13 Laggage 阅读(33) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 实现一个像 Lodash.without 函数一样的泛型 Without<T, U>,它接收数组类型的 T 和数字或数组类型的 U 为参数,会返回一个去除 U 中元素的数组 T。 例如: type Res = Without<[1, 2], 1>; // expected to be [ 阅读全文
posted @ 2022-10-24 23:05 Laggage 阅读(53) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 实现 TrimRight<T> ,它接收确定的字符串类型并返回一个新的字符串,其中新返回的字符串删除了原字符串结尾的空白字符串。 例如 type Trimed = TrimRight<' Hello World '>; // 应推导出 ' Hello World' English Imp 阅读全文
posted @ 2022-10-24 22:41 Laggage 阅读(36) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 Fill是 javascript 中常用的方法, 现在让我实现类型版本的 Fill Fill<T, N, Start?, End?>, 正如你看到的那样, Fill接受四个泛型参数, 其中 T 和 N 是必填参数, Start 和 End 是可选参数 这些参数的要求如下: T 必须是一个 阅读全文
posted @ 2022-10-24 00:28 Laggage 阅读(42) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 你知道 lodash 吗? lodash中有一个非常实用的方法Chunk, 让我们实现它吧. Chunk<T, N>接受两个泛型参数, 其中 T 是 tuple 类型, N是大于 1 的数字 type exp1 = Chunk<[1, 2, 3], 2>; // expected to 阅读全文
posted @ 2022-10-23 22:43 Laggage 阅读(41) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 实现 IsTuple 类型, 接受一个泛型参数 T 作为输入, 并返回 T 是否为 tuple 类型 示例: type case1 = IsTuple<[number]>; // true type case2 = IsTuple<readonly [number]>; // true 阅读全文
posted @ 2022-10-23 21:59 Laggage 阅读(49) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 在本挑战中, 你需要实现 GreaterThan<T, U>, 它的作用像 T > U 你不需要考虑负数 示例: GreaterThan < 2, 1 > //should be true GreaterThan < 1, 1 > //should be false GreaterTha 阅读全文
posted @ 2022-10-23 20:58 Laggage 阅读(35) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 实现类型 AllCombinations<S>,该类型返回字符串 S 中字符的所有排列组合。 English Implement type AllCombinations<S> that return all combinations of strings which use chara 阅读全文
posted @ 2022-10-23 20:21 Laggage 阅读(30) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 实现类型版本的 Array.shift English Implement the type version of Array.shift For example type Result = Shift<[3, 2, 1]>; // [2, 1] 答案 type Shift<T exte 阅读全文
posted @ 2022-10-18 21:42 Laggage 阅读(79) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 实现一个 just-flip-object 类型 示例: Flip<{ a: 'x'; b: 'y'; c: 'z' }>; // {x: 'a', y: 'b', z: 'c'} Flip<{ a: 1; b: 2; c: 3 }>; // {1: 'a', 2: 'b', 3: 'c 阅读全文
posted @ 2022-10-02 17:11 Laggage 阅读(30) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 实现一个输入参数为数字 T 的泛型类型 Fibonacci<T>, 返回 T 对应的斐波那契数 斐波那契数列: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ... 示例: type Result1 = Fibonacci<3>; // 2 typ 阅读全文
posted @ 2022-10-02 16:31 Laggage 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 实现二叉树的中序遍历 示例: const tree1 = { val: 1, left: null, right: { val: 2, left: { val: 3, left: null, right: null, }, right: null, }, } as const; type 阅读全文
posted @ 2022-09-29 21:53 Laggage 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 Block,Element,Modifier 方法(BEM)是 CSS 中类的流行命名约定。 例如,块组件用 btn 表示,依赖于块的元素用 btn__price 表示,更改块样式的修饰符将用 btn--big 或者 btn__price--warning表示。 实现从这三个参数生成字符 阅读全文
posted @ 2022-09-25 21:32 Laggage 阅读(50) 评论(0) 推荐(0) 编辑
摘要: 题目 中文 递归将数组展开到指定的深度 示例: type a = FlattenDepth<[1, 2, [3, 4], [[[5]]]], 2>; // [1, 2, 3, 4, [5]]. flattern 2 times type b = FlattenDepth<[1, 2, [3, 4], 阅读全文
posted @ 2022-09-24 21:38 Laggage 阅读(38) 评论(0) 推荐(0) 编辑