Skip to content

Instantly share code, notes, and snippets.

@Charlie-robin
Last active August 18, 2023 02:44
Show Gist options
  • Save Charlie-robin/c6f08f1d10ce2796de9963e8f8befed4 to your computer and use it in GitHub Desktop.
Save Charlie-robin/c6f08f1d10ce2796de9963e8f8befed4 to your computer and use it in GitHub Desktop.
Chrome console.log() update

Hello 👋,

Chrome has slightly changed the output you get when you are logging a HTML element to the console. You will not get the same output if you log the element the same way as the video.

const itemIWantToLog = document.querySelector("#item");
console.log(itemIWantToLog);

To get the same response to the console in the next video you have two opions which are listed below.

1 A Different Console Method

You can use console.dir(). This displays an interactive list of the properties of the specified JavaScript object. To use it place the item you want to log in the parenthesis.

✔️

const itemIWantToLog = document.querySelector("#item");
console.dir(itemIWantToLog);

2 Wrapping the Element Inside { }

Inside the console.log() you can place the item inside {}. This will do the same thing as console.dir().

✔️

const itemIWantToLog = document.querySelector("#item");
console.log({itemIWantToLog});

Problems?

Any problems feel free to give a coach a message.

@Charlie-robin
Copy link
Author

Good morning @PegliOne thank you for the message, something strange is going on here as it was before the lesson previously.
Now when I go to update the module it will not allow me to publish it. We use a third party for managing our content so I have raised an issue with them as I can not publish the fixed course at the moment.

@PegliOne
Copy link

All good Charlie, hopefully they'll sort it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment