Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

87
Views
VS code debug - is replacing object values with ellipses. How to show object values in debug?

How can I get the debug console to display the actual values of the sorted object?

The result in the VS Code debug console display as below and are non expandable:

[{…}, {…}, {…}, {…}, {…}, {…}]
No debugger available, can not send 'variables'

Here is a simple program outputting a sorted object that I have written in VS Code.

const items = [
    { name: 'Edward', value: 21 },
    { name: 'Sharpe', value: 37 },
    { name: 'And', value: 45 },
    { name: 'The', value: -12 },
    { name: 'Magnetic', value: 13 },
    { name: 'Zeros', value: 37 }
  ];

// sort by value
items.sort(function (a, b) {
    return a.value - b.value;
  });

// console.log(items);

Here is the launch.json file:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": []
}
7 months ago · Juan Pablo Isaza
2 answers
Answer question

0

Important: This solution only works if you are using Node.js.

If you are using Node.js, you can use the built-in util.inspect() function.

First, you have to import it using require().

const util = require("util");

Then, you can call the inspect function. You need to pass in your object as a parameter.

const inspected = util.inspect(obj);
console.log(inspected);

Then, you can easily see the object without it being condensed! For more information, see the util.inspect() documentation.


If you are not using Node.js, you can use JSON.stringify(). You can simply use it as so, passing the object as a parameter.

const obj = [
  { name: "Edward", value: 21 },
  { name: "Sharpe", value: 37 },
  { name: "And", value: 45 },
  { name: "The", value: -12 },
  { name: "Magnetic", value: 13 },
  { name: "Zeros", value: 37 }
];

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

This should allow you to inspect it properly.

7 months ago · Juan Pablo Isaza Report

0

Stringify worked but the output for mine is ugly AF! vscode really sucks in this regard! enter image description here

enter image description here

7 months ago · Juan Pablo Isaza Report
Answer question
Find remote jobs