In the table below the differences of typeof, instanceof and constructor is shown. These three tests are executed on the variable x, which is defined for every testcase in the first column in each row.
typeof | instanceof | constructor | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
boolean | string | number | function | object | undefined | Boolean | String | Number | Function | Object | Array | Boolean | String | Number | Function | Object | Array | {no constructor} |
If you miss a specific testcase, let me know.