diff --git a/extensions/console/02_console.js b/extensions/console/02_console.js index b4b29e1ea8..10819cd6f9 100644 --- a/extensions/console/02_console.js +++ b/extensions/console/02_console.js @@ -351,15 +351,22 @@ const entries = []; let iter; - // TODO(littledivy): Avoid re-checking iterable type - if (ArrayIsArray(value) || isTypedArray(value)) { - iter = ArrayPrototypeEntries(value); - } else if (value instanceof Set) { - iter = SetPrototypeEntries(value); - } else if (value instanceof Map) { - iter = MapPrototypeEntries(value); - } else { - throw new TypeError("Unreachable"); + switch (options.typeName) { + case "Map": + iter = MapPrototypeEntries(value); + break; + case "Set": + iter = SetPrototypeEntries(value); + break; + case "Array": + iter = ArrayPrototypeEntries(value); + break; + default: + if (isTypedArray(value)) { + iter = ArrayPrototypeEntries(value); + } else { + throw new TypeError("unreachable"); + } } let entriesLength = 0;