Ask Your Question

In what way can I modify the width of the printed output of node's console.log?

asked 2022-08-28 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-03-28 02:00:00 +0000

lalupa gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer

Question Tools


Asked: 2022-08-28 11:00:00 +0000

Seen: 7 times

Last updated: Mar 28 '22