To modify the width of the printed output of node's console.log, you can use the util.inspect
method with the maxWidth
option.
Here's an example:
const myObj = {
name: "John Doe",
age: 30,
location: "New York"
};
console.log(util.inspect(myObj, {maxWidth: 50}));
In this example, the util.inspect
method is used to print the myObj
object with a maximum width of 50 characters. You can change the maximum width to your desired value.
Asked: 2022-08-28 11:00:00 +0000
Seen: 10 times
Last updated: Mar 28 '22