JavaScript Output


JavaScript Output specifies how to display the results of a given code. The result can be shown in four distinct ways, as detailed below:

1. innerHTML:

It is used to access an element. It defines the HTML content.

Syntax

Example

Preview

2. document.write():

It is used for testing purposes.

Syntax

Example

Preview

3. window.alert():

It displays the content using an alert box.

Syntax

Example

Preview

4. console.log():

It is used for debugging purposes.

Syntax

Example

Preview