Skip to content

Inconsistent behaviour for instanceof for Array type and array literal returned from new context #3425

@NoelAbrahams

Description

@NoelAbrahams

Hi,

The following code works as expected:

> var context = { Array: Array };
undefined
> vm.runInNewContext("var a = new Array();", context)
undefined
> context.a instanceof Array
true
> 

However, when Array is replaced with an array literal the instanceof assertion fails:

> vm.runInNewContext("var a = [];", context)
undefined
> context.a instanceof Array
false

Due to dependent library reasons we are currently running node version 0.10.33.

Is this a bug or is there a way around this?

Thanks.

Edit:

The assertion Array.isArray(context.a); returns true for both cases, but I'd like to know why the instanceof is failing

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidIssues and PRs that are invalid.vmIssues and PRs related to the vm subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions