check if object instance of class core interview pattern 模式
1 道题目
模式页适合用来建立可复用解题框架。先识别题目特征,再按固定流程解释状态定义、转移和边界。
识别信号
- Candidate's ability to handle inheritance and prototype chains in JavaScript.
- Understanding of how `instanceof` works in JavaScript and potential pitfalls.
解题流程
- 1. 明确窗口/状态定义
- 2. 更新状态并维护约束
- 3. 用边界样例验证
常见失分点
- Forgetting that `instanceof` will check both the class and its parent classes, which can lead to incorrect results if not handled properly.