
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to display output in javascript?
There are 4 ways to display the output in JavaScript.
a) Displaying the output in HTML elements, using innerHTML attribute.
Example
<html> <body> <p id="display"></p> <script> document.getElementById("display").innerHTML = 10 + 10; </script> </body> </html>
Output
20.
b) Displaying the output using document.write().
Example
<html> <body> <script> document.write(2 + 3); </script> </body> </html>
Output
5
c) Displaying the output through console.log().
Example
<html> <body> <script> console.log(2 + 3); </script> </body> </html>
In debugger console, the output
5.
d) Displaying the output through alert box.
Example
<html> <body> <script> alert(2 + 3); </script> </body> </html>
In alert window box, the output
5
In case of handling json strings, or some other big data console.log is the best choice.
- Related Articles
- How to display specific properties from Get-Service output in PowerShell?
- How to output JavaScript into a Textbox?
- How to selectively retrieve value from json output JavaScript
- How to display p-value with coefficients in stargazer output for linear regression model in R?
- Java Program to display table with columns in the output using Formatter
- How to display value of textbox in JavaScript?
- Display Command Output or File Contents in Column Format in Linux
- How to display HTML element with JavaScript?
- How to display only the current year in JavaScript?
- How to display JavaScript variable value in alert box?
- How to output MySQL query results in CSV format and display it on the screen, not a file?
- How to obtain the same font in Matplotlib output as in LaTex output?
- How to make flexible items display in columns with JavaScript?
- How to sort the output in PowerShell?
- How to get radiobutton output in Tkinter?

Advertisements