What is JavaScript ?
Is the programming language of the Web, enables you to create daynamic updating content, control multimedia, animate images and pretty everythings, it executed line by line and have the .js extension.
## Variables :
Can store data in variables.
Syntax
var VarName(should be a valid identifier) = variable value ;
## JavaScript Data Types :
-
Number :
var age= 24;
-
String :
var name="saja" // double cotation. var name='saja' // single cotation.
-
Boolean :
var ischecked= true or false;
JavaScript Output :
-
Using console.log()
console.log(‘first name’ + fname)
-
Using document.write()
document.write(‘first name’ + fname)
-
Using alert() (message box)
alert(‘what your name’)
JavaScript Comments :
Using comments to prevent execution
- Single line comments start with // .
- multi line comment start with /* and end with */ .
Window prompt() Method :
Display a prompt box which ask the user for anythings like name , age , etc .
var fname= prompt("Please enter your name", "your name");
JavaScript if else :
Are used to do different actions based on different conditions.
if(condition==true)
{
// do some thing if true
else
{
// do some thimg if not true
}
}