Dialog boxes() – Display output using alert, prompt and confirm dialog boxes
document.write() – Used to insert text onto your web page (this text can actually be HTML elements).
innerHTML – Used to display output in a specific place or in a division
console.log() – Used to display output on the console of a browser.
A variable is basically an identifier for a value or simply the Variables are used to store values or expressions
The way to use variables is by using the var keyword followed by the variable name.
In this line of code, I declared a variable called empName. Right now, It doesn’t contain any value. So initialization is required here –
var empName = “Hernan”;
Following things should be follow when naming them:
– Your variable name should be meaningful or be a noun.
– Your variables can start with a letter, underscore, or the $, they can’t start with a number.
– Spaces are not allowed.
– Variable name should be unique and should not be a keyword.
A function is nothing more than a wrapper for some code. A function is a block of code which will be executed only if it is called.
So A Function is a:
– Groups statements together
– Makes your code reusable
//Set of statements here
alert(“hello.. Lets learn functions in JS”);
The last thing to look at is the function call: