1

I'm using VS Code as text editor for JavaScript, and Node.js for debugging my codes. When I debug the following code I get something called Object, I suppose it refers to something, but why doesn't it display what it refers to, and how can I do it? Is it related to my code?

function arrayToList(array) {
    let list = null;
    for (let i = array.length - 1; i >= 0; i--) {
      list = {value: array[i], rest: list};
    }
    return list;
}
let a = arrayToList([1,3]);
console.log(a);

This is the result (I also added a screen shot of it):

> Object {value: 1, rest: Object}

What is shown in Debug Console

3

2 Answers 2

4

Vs code will only show the top levels. It wont show an object inside of an object. But you can do something like this to still show the entire object:

console.log(JSON.stringify(a));

OR:

console.log(a.rest)
Sign up to request clarification or add additional context in comments.

Comments

0

Try

console.log(JSON.stringify(a)) Or

console.log(a.rest)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.