Μετάβαση στο κύριο περιεχόμενο
Το Frontend είναι ένα δωρεάν μπόνους στο CodeMentor AI — το κύριο προϊόν είναι η Python. Εγγραφείτε για να αποθηκεύσετε την πρόοδό σας και να ξεκλειδώσετε όλα τα 299 μαθήματα Frontend + 1,100+ μαθήματα Python.Εγγραφή — δωρεάν
← ⚡ JavaScript & the browser·Ενότητα C1 · Μάθημα 1
ΕργασίαInside the <script> tag, log the string 'Hello from JS' so the embedded console shows it.

console.log: η πρώτη σας γραμμή JavaScript

50 XP5 minFREE
Θεωρία

Where JavaScript runs

Every page can run JavaScript. Drop a <script> tag anywhere in your HTML and the browser executes it.

<script>
  console.log("Hello from JS");
</script>

console.log writes to the browser's developer console (Cmd+Opt+J on Mac, F12 on Windows). It's the simplest "is this code even running?" check, and you'll keep using it for the rest of your career.

What console.log accepts

Anything. Strings, numbers, arrays, objects, multiple arguments separated by commas.

console.log("a number:", 42);
console.log({ name: "Anna", age: 30 });
console.log([1, 2, 3], "and a tail");

The browser pretty-prints objects so you can expand them. That's why "log the whole thing" beats "log six different pieces of it" while you're debugging.

console.log vs alert

Old tutorials use alert() to show output. Don't. alert blocks the page until you click it, breaks every modern workflow, and is the kind of thing that gets your code mocked on PRs.

console.log is the right tool, every time.

2 καρτέλες
Ζωντανή προεπισκόπηση
console output appears here…
← Στη διαδρομήΕπόμενο μάθημα →

Μια συμβουλή Python ή web την ημέρα — με email

Σύντομο, γραμμένο στο χέρι, χωρίς spam. Διαγραφή με ένα κλικ.