util 裏面提供的四個類型檢查函數
util.isArray(object)
util.isRegExp(object)
util.isDate(object)
util.isError(object)
JavaScript 不是直接提供了 instanceof 嗎?Node.js 幹嘛要設計這四個函數,有多餘之嫌。
1 回复
As noted in the source
// NOTE: These type checking functions intentionally don't use `instanceof`
// because it is fragile and can be easily faked with `Object.create()`.