JavaScript Output 

There are four ways of displaying data in javascript.
  1. Displaying into an Html element, by using innerHTML.
  2. Displaying into browser console log, by using cosole.log().
  3. Displaying into an alert box, by using window.alert().
  4. Displaying in to the HTML output, using Document.write().
1. JavaScript output using innerHTML
You can display output inside an Html element using innerhtml and getElementById() method as follows.
Example:
<!DOCTYPE html>
<html>
<body>

<h1>JS Output using Innerhtml</h1>

<p id="jo"></p>

<script>
document.getElementById("jo").innerHTML = 10 + 8;
</script>

</body>
</html> 
Output



JS Output using Innerhtml

2. JavaScript output using cosole.log().
You can also display output on your browser console log using cosole.log(). You can activate the console log on your browser by using F12 .
Example:
<!DOCTYPE html>
<html>
<body>

<h1>JS Output using console.log()</h1>

<script>
console.log(10 + 8);
</script>

</body>
</html> 
Output 

3. JavaScript output using window.alert()
You can also display output in the alert box using window.alert().
Example:
<!DOCTYPE html>
<html>
<body>
<script>
window.alert(10 + 8);
</script>

</body>
</html> 
Output:

4.JavaScript output using Document.write()
Document.write() is the other alternative to display javascript data output. it uses to display javascript output in Html output.
Example:
<!DOCTYPE html>
<html>
<body>

<h1>JS Output using document write</h1>


<script>
document.write(10 + 8);
</script>

</body>
</html> 
Output





JS Output using document write