Part of JavaScript/TypeScript/NodeJS

๐Ÿš€ Learn JavaScript Console Basics in this beginner-friendly tutorial!

Sandy LaneSandy Lane
โ€ข

Video: ๐Ÿš€ Learn JavaScript Console Basics in this beginner-friendly tutorial! by Taught by Celeste AI - AI Coding Coach

Take the quiz on the full lesson page
Test what you've read ยท interactive walkthrough
โ†’

๐Ÿš€ Learn JavaScript Console Basics in this beginner-friendly tutorial!

Understanding how to use console.log() is a fundamental skill for debugging JavaScript code. This tutorial covers printing messages, displaying variables, and using multiple arguments in console.log() to help you quickly inspect and troubleshoot your code.

Code

// Print a simple message to the console
console.log("Hello, World!");

// Declare a variable and print it with a greeting
const name = "Alice";
console.log("Hello, " + name);

// Print multiple values and their types in one line
console.log("Value:", 42, "Type:", typeof 42);

Key Points

  • console.log() prints messages and variables to the browser console for debugging.
  • You can concatenate strings and variables using the + operator inside console.log().
  • Multiple arguments separated by commas can be passed to console.log() to print values and labels together.
  • Using typeof inside console.log() helps quickly check variable types during debugging.
  • Regularly using console.log() makes it easier to understand code flow and find errors early.
Ready? Take the quiz on the full lesson page โ†’
Test what you've learned. Watch the lesson and try the interactive quiz on the same page.
โ†’