Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

console.log: wrong output when using '\' in Object keys #6835

Closed
@avetisk

Description

@avetisk

Case 1

Adds an extra '' when key is ending with 2+ ''.

var obj = {
  '\\': 1,
  '\\\\': 2,
  '\\\\\\': 3,
  '\\\\\\\\': 4,
};
console.log(obj);

Expected:

{ '\': 1, '\\': 2, '\\\': 3, '\\\\': 4 }

Got:

{ '\': 1, '\\\': 2, '\\\\\': 3, '\\\\\\\': 4 }

Case 2

Leaves '' as they are

var obj = {
  '\\sometext': 1,
  '\\\\sometext': 2,
  '\\\\\\sometext': 3,
  '\\\\\\\\sometext': 4,
};
console.log(obj);

Expected:

{ '\sometext': 1, '\\sometext': 2, '\\\sometext': 3, '\\\\sometext': 4 }

Got:

{ '\\sometext': 1, '\\\\sometext': 2, '\\\\\\sometext': 3, '\\\\\\\\sometext': 4 }

Case 3

Any following '' is not resolved any more.

var obj = {
  '\\': 1,
  '\\\\': 2,
  '\\\\\\': 3,
  '\\\\\\\\': 4,
};
console.log(obj, 'a\nb', '\\', '\\\\', '\\\\\\');

Expected:

{ '\': 1, '\\': 2, '\\\': 3, '\\\\': 4 } 'a
b' '\' '\\' '\\\'

Got:

{ '\': 1, '\\\': 2, '\\\\\': 3, '\\\\\\\': 4 } 'a\nb' '\\' '\\\\' '\\\\\\'

Nota Bene

It's really about console as this produces no error:

assert(Object.keys({'\\': 1, '\\\\': 2})[1].length === 2)

Info

  • node 0.10.22
  • tested both on OS X 10.9 and Ubuntu 13.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions