Generating Output in JavaScript
In the previous tutorials , we talked about Variables and strings. So in this tutorial, we would be talking about how to generate output in JavaScript.
Supposed you have to add the value of x and y to get z. The z will be the output in JavaScript. And that is what we call generating output. There are times you might need display message to the user. All this is done by generating output.
There are several ways of generating output in JavaScript and we will be covering all.
Lets begin. I want you to put your mind to this and if you have any difficulty in understanding this, please comment.
Generate Output to Browser Console
This is the most used method when it comes to generating output. This method is very simple. You can decide to Output a string , calculate , send a message etc.
Let's see how it works.
To generate Output to Browser, you use the
console.log( ) method.
Here is an example
console.log("Hello world");
Generate Output to Browser Window
This is another method used to generate output. To generate output , you use
document.write( ) method.
Example
document.write ("Hello world");
Display in Dialog box
This is also one of the most used method. This is very suitable for web development. You create a dialog alert box using the
alert( ) method.
Example
Please share
JavaScript Syntax
Where do you place JavaScript in HTML document
JavaScript Variables
JavaScript Strings: How to create and manipulate
JavaScript If, If else, If else if statement
JavaScript Function: How to define and call a function
JavaScript Switch case
Comments
Post a Comment