
Description
- Version: 12.18.2
- Platform: Linux 55f6f10199d3 5.4.0-1019-gcp Multiple persistent child-process-related test failures on Windows when running as a Service #19-Ubuntu SMP ... x86_64 x86_64 x86_64 GNU/Linux
- Subsystem: Unknown
What steps will reproduce the bug?
"use strict";
console.log(
"%s\n%s\n%s\n%s\n%s\n%s",
typeof [] === "object", // supposed to be true
[] instanceof Object, // supposed to be true
[] instanceof Array, // supposed to be true
Array.isArray([]), // supposed to be true
Symbol.iterator in [], // supposed to be a true
Object.getPrototypeOf([]) === Array.prototype // supposed to be true
);
How often does it reproduce? Is there a required condition?
100% reproduction rate, it always has the same results.
What is the expected behavior?
It is expected that object literals share their prototype with Object
, and that array literals share their prototype with Array
, thus an instanceof
check against Object
or Array
respectively should show true
, and this is true for all browsers, Deno, is documented at MDN, yet I couldn't find what the ECMAScript spec had to say about this.
Interestingly, the Node terminal repl showed the expected results, while running a file didn't.
This was run in strict mode and in sloppy mode, without a difference in output.
What do you see instead?
Array literals do not share the prototype of the global Array
class.
Additional information
This may not be standard compliant, and shouldn't break any legacy code, as it would be odd to check that an array is an array through an instanceof
check instead of Array.isArray
.