上一页 1 ··· 120 121 122 123 124 125 126 127 128 ··· 498 下一页
摘要: Requirements: function strBuilder(str) { return strBuilder; // TODO } var hello = strBuilder("Hello, "); var kyle = hello("Kyle"); var susan = hello(" 阅读全文
posted @ 2022-08-03 19:56 Zhentiw 阅读(31) 评论(0) 推荐(0)
摘要: value is Foo The first kind of user-defined type guard we will review is an is type guard. It is perfectly suited for our example above because it’s m 阅读全文
posted @ 2022-08-03 13:23 Zhentiw 阅读(75) 评论(0) 推荐(0)
摘要: class UnreachableError extends Error { constructor(_nvr: never, message: string) { super(message) } } class Car { drive() { console.log("vroom") } } c 阅读全文
posted @ 2022-08-03 01:59 Zhentiw 阅读(18) 评论(0) 推荐(0)
摘要: For the following class: class Car { make: string model: string year: number constructor(make: string, model: string, year: number) { this.make = make 阅读全文
posted @ 2022-08-01 17:17 Zhentiw 阅读(53) 评论(0) 推荐(0)
摘要: function f(...args) { return args; } function flip(fn) { return function flipped (arg1, arg2, ...args) { return fn(arg2, arg1, ...args) } } let z = fl 阅读全文
posted @ 2022-07-31 16:45 Zhentiw 阅读(41) 评论(0) 推荐(0)
摘要: Construct signatures are similar to call signatures, except they describe what should happen with the new keyword. interface DateConstructor { new (va 阅读全文
posted @ 2022-07-28 15:46 Zhentiw 阅读(92) 评论(0) 推荐(0)
摘要: Recursive types, are self-referential, and are often used to describe infinitely nestable types. For example, consider infinitely nestable arrays of n 阅读全文
posted @ 2022-07-27 19:15 Zhentiw 阅读(51) 评论(0) 推荐(0)
摘要: An interface is a way of defining an object type. An “object type” can be thought of as, “an instance of a class could conceivably look like this”. Fo 阅读全文
posted @ 2022-07-27 19:14 Zhentiw 阅读(54) 评论(0) 推荐(0)
摘要: function flipCoin(): "heads" | "tails" { if (Math.random() > 0.5) return "heads" return "tails" } function maybeGetUserInfo(): | ["error", Error] | [" 阅读全文
posted @ 2022-07-26 14:50 Zhentiw 阅读(56) 评论(0) 推荐(0)
摘要: 1. const values = [3, "14", [21]] for (let a in values) { // ^? } for (let b of values) { // ^? } . . . . Answer: for...in loop: The for...in statemen 阅读全文
posted @ 2022-07-26 14:24 Zhentiw 阅读(51) 评论(0) 推荐(0)
上一页 1 ··· 120 121 122 123 124 125 126 127 128 ··· 498 下一页