JAVA SCRIPT:
def: java script syntax refers to the set of rules for writing the java script code
, like statements ,variables,functions etc .
1) VARIABLE DECLARATION : an identifier
variable declaration in java script in dynamically programmed language .
Dynamically -> "at the time of execution " .
dynamically assigning the value by giving the variable name . an identifier is also
a variable but it stores the address of the value .
NOTE: java script is a programmed language . which means at the time of exectuion
we can assign the value to the variable
TYPES OF VARIABLE DECALARTION :
1) "let" = by using the let keyword we are assigning the variable .where we can
access any where inside the block of code .
by calling it with the variable name .
2) "var"= by using the var keyword . we can access the variable both inside and
outside of the block (But not the oustide of the class object ) .
3) "consist or constant = by using the const keyword . we can assign the value to
the variable . once value assigned we cant change . it is fixed a value .
NOTE: let and const are blocked scoped and the var is the scoped .
JAVA SCRIPT DATA TYPES :
in java scriot we have primitive and non primitive data types .
Primitive data types :
1) String (alphabetical character to the variables)
2) Numbers( numerical and decimal point character either positive or negative)
3) Boolean
4) null
5) undefined
to store infinite length of the numeric value , ( exp: Ankur warikoo networth of 10
million dollars )
let city ="New york";//string
let isSunny=true; //boolean
let temperature=32.5 //number
let score= null;
let x; //undefined
non-Primitve data type :
it will accept who are more types of data values stored in a single variable.
1) Object = we can store the multiple data values
2) array = it is an object but it will accept only the same group of elements .
to store the similar type of the data for a significant values of the multiple
stored in a single variable . we call it as a array .
3) function = it is a block of code . it can represent error message or greeting
message to the end user by using function calling . { [Link]}
java script console flow :
=> java script uses standard control flow strcutures .
TYPES OF CONTROL FLOW STATEMENTS :
1) if condition
2) if-else condition
3) if-elif-else condition
Examples :
=> if condition
let a=10
if (a>=5){
[Link]("it is small number " )
}
if if condition is used to execute the block of the code . then the condition is
satisfied or true .
=> if else condition :
let a=10
if(a>=15){
[Link](a,"It is small number " )
}
else{
[Link](a,"It is big number ")
}
if "if" block is not satisfied then the else block will continue.
multiple conditions to perform the single operation .
=> if elif else
for the usage of else if block
first you we need to mention the if condition once , if condition is not satisfied
then the conditional statement passed through the "Else-if" block .
2) Even though the esle if else if block is not satisfied then else block will be
executed .
example :
if( a>=15){
[Link](a,"It is smll number")
}
else if(a<=15){
[Link](a,"It is small number ")
}
else(
[Link]( a,"It is big number")
}
NESTED IF :
once the main if condition (parent condition) satisfied then the block of the code
will executed ,
also it will check the nested if condition then that condition is also satisfied
then nexted if block of code will be executed .
create files for each primitive data types
five examples for each control statement