diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2020-10-07 21:08:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-07 16:08:54 -0400 |
commit | 8bd7c936f9a9a63334e5f512d6b6c1f8b47a42b8 (patch) | |
tree | 5c668bd603ceecfa0d81a9baf1c9a135e6406693 /cli/rt/02_console.js | |
parent | 46e9758962e0d9a514fc9678bf553abdd7185ae3 (diff) |
fix(cli/rt/console): Don't require a prototype to detect a class instance (#7869)
Diffstat (limited to 'cli/rt/02_console.js')
-rw-r--r-- | cli/rt/02_console.js | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/cli/rt/02_console.js b/cli/rt/02_console.js index 8c853deb9..72192eda4 100644 --- a/cli/rt/02_console.js +++ b/cli/rt/02_console.js @@ -175,18 +175,13 @@ /* eslint-disable @typescript-eslint/no-use-before-define */ function getClassInstanceName(instance) { - if (typeof instance !== "object") { + if (typeof instance != "object") { return ""; } - if (!instance) { - return ""; - } - - const proto = Object.getPrototypeOf(instance); - if (proto && proto.constructor) { - return proto.constructor.name; // could be "Object" or "Array" + const constructor = instance?.constructor; + if (typeof constructor == "function") { + return constructor.name ?? ""; } - return ""; } |