Skip to content

Bug in console.log ? #11651

@LakshmiSwethaG

Description

@LakshmiSwethaG

I have this code. As you can see, the stringified version of the obejct, and the representation used by console.log are different. Is it a bug, or a limitation in the console.log?

function parse() {
var cont = [];
var obj = {};
cont.push(obj);
var arr = [];
obj['sw'] = arr;
arr.push(1);
return cont;
}

var obj = {};
var a = 'ee';
obj[a] = parse();
console.log(JSON.stringify(obj));
console.log(obj);


Output:

{"ee":[{"sw":[1]}]}
{ ee: [ { sw: [Object] } ] }  

Metadata

Metadata

Assignees

No one assigned

    Labels

    consoleIssues and PRs related to the console subsystem.questionIssues that look for answers.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