Skip to content

Doubled array entry using index '' in node v8.4.0 #15159

Closed
@lucaelin

Description

@lucaelin

As of node v8.4.0, assigning a value to the array index '' causes a duplicate entry to be created. The duplicate disappears (and cannot be recreated) as soon as a value is assigned to a numerical index.

let x = [];
x[''] = 'foo';
console.log(x); 
// [ '': 'foo', '': 'foo' ]

console.log(x[0]); 
// undefined
x[0] = 'bar';
console.log(x);
// [ 'bar', '': 'foo' ]

x[''] = 'baz';
console.log(x);
// [ 'bar', '': 'baz' ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    testIssues and PRs related to the tests.utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions