Show Output of JavaScript Code

Show Output of JavaScript Code

Instructor-svgAl-Mamun Sarkar
Mar 29 , 2021

There are four-way for showing the output of JavaScript codes. Each one has a different use case. Showing output systems are as follows. 

innerHTML: For show output inside HTML tag.

document.write(): Display Output Into HTML.

alert(): Show alert box.

console.log(): Showing Output in the browser console. 

 

Example:

<!DOCTYPE html>
<html>
<head>
	<title> Displaying Output </title>
</head>
<body>

<h2>Show Ouput</h2>
<p id="myId"></p>

<script>
	document.write("Write Output on the document");
  	document.getElementById("myId").innerHTML = "This is JavaScript Example";
  	console.log("Show Output on Brawser console");
  	alert("This is an alert");
</script>

</body>
</html>

 

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram