| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 33e51fe commit 54cbf28
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -335,6 +335,22 @@ util.isError({ name: 'Error', message: 'an error occurred' }) | |||
| 335 | 335 | // false | |
| 336 | 336 | ``` | |
| 337 | 337 | ||
| 338 | + Note that this method relies on `Object.prototype.toString()` behavior. It is | ||
| 339 | + possible to obtain an incorrect result when the `object` argument manipulates | ||
| 340 | + `@@toStringTag`. | ||
| 341 | + | ||
| 342 | + ```js | ||
| 343 | + // This example requires the `--harmony-tostring` flag | ||
| 344 | + const util = require('util'); | ||
| 345 | + const obj = { name: 'Error', message: 'an error occurred' }; | ||
| 346 | + | ||
| 347 | + util.isError(obj); | ||
| 348 | + // false | ||
| 349 | + obj[Symbol.toStringTag] = 'Error'; | ||
| 350 | + util.isError(obj); | ||
| 351 | + // true | ||
| 352 | + ``` | ||
| 353 | + | ||
| 338 | 354 | ## util.isFunction(object) | |
| 339 | 355 | ||
| 340 | 356 | Stability: 0 - Deprecated | |
| Back | FazBrowse Home | New Git URL |
0 commit comments