JavaScript Output defines the ways to display the output of a given code. The output can be display by using four different ways which are listed below:
- innerHTML: It is used to access an element. It defines the HTML content.
Syntax:
document.getElementById(id)
Example: This example uses innerHTML to display the data.
<!DOCTYPE html><html><head><title>JavaScript Output using innerHTML</title></head><body><h1>GeeksforGeeks</h1><h2>JavaScript Display PossibilitiesUsing innerHTML</h2><pid="GFG"></p><!-- Script to uses innerHTML --><script>document.getElementById("GFG").innerHTML= 10 * 2;</script></body></html>chevron_rightfilter_noneOutput:

- document.write(): It is used for testing purpose.
Syntax:
document.write()
Example: This example uses document.write() property to display data.
<!DOCTYPE html><html><head><title>JavaScript Output using document.write()</title></head><body><h1>GeeksforGeeks</h1><h2>JavaScript Display PossibilitiesUsing document.write()</h2><pid="GFG"></p><!-- Script to uses document.write() --><script>document.write(10 * 2);</script></body></html>chevron_rightfilter_noneOutput:

- window.alert():It displays the content using an alert box.
Syntax:
window.alert()
Example: This example uses window.alert() property to display data.
<!DOCTYPE html><html><head><title>JavaScript Output using window.alert()</title></head><body><h1>GeeksforGeeks</h1><h2>JavaScript Display PossibilitiesUsing window.alert()</h2><pid="GFG"></p><!-- Script to use window.alert() --><script>window.alert(10 * 2);</script></body></html>chevron_rightfilter_noneOutput:


- console.log(): It is used for debugging purposes.
Syntax:
console.log()
Example: This example uses console.log() property to display data.
<!DOCTYPE html><html><head><title>JavaScript Output using innerHTML</title></head><body><h1>GeeksforGeeks</h1><h2>JavaScript Display PossibilitiesUsing console.log()</h2><pid="GFG"></p><!-- Script to use console.log() --><script>console.log(10*2);</script></body></html>chevron_rightfilter_noneOutput:

Recommended Posts:
- Output of PHP programs | Set 1 (Regular Expressions)
- Output of PHP programs | Set 2 ( Filters )
- Output of PHP programs | Set 3
- PHP | Output Buffering
- Output of PHP programs | Set 4
- Code valid in both C and C++ but produce different output
- HTML | <output> Tag
- HTML | <output> name Attribute
- HTML | <output> form Attribute
- HTML | DOM Output form Property
- HTML | DOM Output type Property
- HTML | DOM Output value Property
- HTML | DOM Output htmlFor Property
- HTML | DOM Output name Property
- How to write sample output of a computer program using HTML5 ?
- How to display output data in tabular form in Node.js ?
- Printing Output of an R Program
- Printing Output on Screen in Julia
- Storing Output on a File in Julia
- HTML | <output> for Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


