Last active
August 23, 2019 14:58
-
-
Save patarapolw/59303874438a521370859d507c0429b6 to your computer and use it in GitHub Desktop.
JavaScript instance type checking.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isSameType(a, b) { | |
const tA = typeof a; | |
const tB = typeof b; | |
if (tA !== "object") { | |
return tA === typeof b; | |
} else if (tB === "object") { | |
return a.constructor === b.constructor; | |
} | |
return tA === tB; // always false??? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment