Module 1: Introduction to JavaScript and Programming
Your First Program: console.log("Hello, World!")
The console.log()
function is a fundamental tool for JavaScript developers. It's used to print messages or data to the browser's developer console or the terminal (if using Node.js).
Here's how you write a "Hello, World!" program:
console.log("Hello, World!");
When this code runs, the message "Hello, World!" will be displayed in the console.
You can log different types of data:
console.log("This is a string."); console.log(123); // A number console.log(true); // A boolean value let myVariable = "Plenty of π"; console.log(myVariable); // The value of a variable