Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
27 views12 pages

If Switch Case Loop Statements - L3

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views12 pages

If Switch Case Loop Statements - L3

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

OUTLINE

• If Statement
• Switch case Statement
• Loop Statement
• Querying and setting properties
• Property getters and setters
IF STATEMENTS
If Statement

If else Statement
IF STATEMENTS
If else---if Statement
if(conditional expression1)
{
//code1
}
else if(conditional expression2)
{
//code2
}
else if(conditional expression3)
{
//code3
}
else
{
//code 4
}
IF STATEMENTS
Nested If else
if(conditional expression1)
{
//code1
if(conditional expression2)
{
//code2
}
else
{
//code3
}
}
else
{

}
SWITCH CASE STATEMENT
LOOP STATEMENT
Java script supports following loop statements
• for loop
• for in
• while loop
• do while loop
• Syntax of for in
for (key in object)
{
//code block
}
QUERYING AND SETTING PROPERTIES
• To obtain value of property dot (.) or square bracket operators are
used
• Syntax
Object_name.Property_name
OR
Object_name[“Property_name”]

• For example
let studobj = {Name:"Jhon",Rollno:1104,Marks:92.78};

nm = studobj.Name;
mk = studobj["Marks"];
studobj["Marks"] = 87.23;
QUERYING AND SETTING PROPERTIES
Adding and deleting object properties
• New property can be added using following syntax:

Object_name.New_Property_name = Value;
OR
Object_name[“Property_name”] = Value;
• Property can be deleted by using following syntax:
delete Object_name.Property_name ;
OR
delete Object_name [“Property_name”] ;
PROPERTY GETTERS AND SETTERS
• There are two types of object properties –
• The first kind is data properties (which we have been using until
now)
• Second type of property is an accessor property
• Accessor properties are essentially functions that execute on
getting and setting a value, but look like regular properties to an
external code

You might also like