DrillLab
练习Practice

动手做Get your hands on it

练习跟着课文走 —— 每节课尾都有本课的练习。这一页是全部练习的总库,想集中刷题的时候来。 每个练习都写清了它来自哪一节,卡住了就回去看那一节。Practice follows the lessons — every lesson ends with the exercises for that lesson. This page is the whole library, for when you want to drill in one sitting. Each exercise names the lesson it came from, so you can go back when you stall.

0 / 148个做对过you got right

练习Exercises

筛出 56 个练习(共 148 个) · 第 5 / 5 页。Showing 56 of 148 · page 5 / 5.
来自From 16 道题逐题对照The 16 problems, compared one by one · 面试八股Interview questions
L1认出来Spot it认出考点:这道题在考什么Name the point: what is this question testingDrillLab 自出Written by DrillLab

面试官出题:「实现一个 Kanban 看板,卡片可以在三列之间移动。」 这道题最核心的考点是哪一个?

The interviewer says: “Build a Kanban board where a card can move between three columns.” Which is the central point this question tests?

先选一个选项Pick an option first
来自From Utility Types:会用,还要会手写Utility types: use them, and write them yourself · 面试八股Interview questions
L1认出来Spot it认出这个 mapped type 在干什么Work out what this mapped type doesDrillLab 自出Written by DrillLab

面试官给出下面这个类型,问它对 T 做了什么。

An interviewer shows you the type below and asks what it does to T.

TypeScriptMystery.ts示意Illustrative
1type Mystery<T> = {
2 [K in keyof T]-?: T[K];
3};
先选一个选项Pick an option first
来自From 泛型与收窄:把 any 赶出代码Generics and narrowing: getting any out of the code · 面试八股Interview questions
L1认出来Spot itunknown 参数该怎么用起来How to actually use an unknown parameterDrillLab 自出Written by DrillLab

这个函数编译不过:'e' is of type 'unknown'.下面哪种改法是对的?

This function does not compile: 'e' is of type 'unknown'. Which fix is the right one?

TypeScriptreport.ts示意Illustrative
1function report(e: unknown) {
2 console.log(e.message);
3 // ^ ✗ 'e' is of type 'unknown'.
4}
先选一个选项Pick an option first
来自From 先读四个测试:它们到底要什么Read the four tests first: what exactly they ask for · Cab BookingCab Booking
L1认出来Spot it哪个断言决定了「分组顺序」不能自己定?Which assertion makes the group order fixed?
测试 2 里有一行让「Sedan / SUV / Luxury 的顺序」变成硬要求。是哪一行?One line in test 2 turns the order of Sedan / SUV / Luxury into a hard requirement. Which line?
先选一个选项Pick an option first
来自From 用一个 state 管四个页面Controlling four pages with one piece of state · Cab BookingCab Booking
L1排顺序Order it把一次完整预订的六步排好Put the six steps of one full booking in order
从点「Book a Cab」到历史里出现记录,中间发生了什么?按顺序排。What happens between pressing “Book a Cab” and the record appearing in the history? Put the steps in order.
1setCurrentPage("cab-options")
2updateBookedCabDetails(cab) —— 写 Context 的两个 stateupdateBookedCabDetails(cab) — writes both states in the Context
3setCurrentPage("loading")
4Loading 的 useEffect 里 setTimeout 1000ms 到期The setTimeout of 1000ms inside the useEffect of Loading fires
5onComplete() → setCurrentPage("cab-confirmation")
6onConfirm() → setCurrentPage("home"),首页读到新的 rideHistoryonConfirm() → setCurrentPage("home"), and the home page reads the new rideHistory
来自From 按类型分组渲染六张卡Rendering the six cards grouped by type · Cab BookingCab Booking
L1认出来Spot it哪个 key 在历史列表里会出问题?Which key goes wrong in the history list?
用户连订了两次同一辆 Ford Fusion(id: 1)。 历史列表用下面哪个 key 会报「重复 key」警告?The user books the same Ford Fusion (id: 1) twice in a row. Which of these keys makes the history list warn about duplicate keys?
先选一个选项Pick an option first
来自From 历史与确认页:两个小而致命的细节The history and confirmation pages: two small details that decide pass or fail · Cab BookingCab Booking
L1认出来Spot it哪些写法能让测试 4 全绿?(多选)Which versions make test 4 pass? (more than one)
历史是 [Fusion, Accord, Highlander, Explorer](最旧 → 最新)。 断言要求:3 条、顺序Explorer / Highlander / AccordFusion 不在 DOM 里。The history is [Fusion, Accord, Highlander, Explorer] (oldest → newest). The assertions want: 3 entries, in the order Explorer / Highlander / Accord, and Fusion not in the DOM.

这题是多选。More than one answer is correct.

先选一个选项Pick an option first
来自From 完整答案跑不起来 —— 一个扩展名的事The complete answer does not run — the cause is one file extension · Cab BookingCab Booking
L1认出来Spot it下面哪些说法是对的?(多选)Which of these statements are correct? (more than one)
关于源项目那两处「能过但可以更好」的写法。About the two places in the source project that pass the tests but could be better.

这题是多选。More than one answer is correct.

先选一个选项Pick an option first