Home › JavaScript Tutorial › JS output
JS output
Four ways to show results.
textContent or innerHTML write into the page, console.log writes to the developer console, and alert opens a dialog.
Commands in this lesson
console.log
Definition: Prints a value for debugging.
Syntax:
console.log(value);
Example:
console.log("Sum:", 2 + 3);Example code
<p id='a'></p><div id='b'></div>
<script>
a.textContent='Plain text';
b.innerHTML='<b>Bold</b> via innerHTML';
console.log('See the console');
</script>