SlideShare a Scribd company logo
Operators and Statements
       Session 9
Objectives
   Describe assignment operators
   Explain bitwise operators
   Explain switch-case statement
   Describe regular expression
Types of Operators
   Operators help in simplifying expressions.
   JavaScript provides a predefined set of operators
    that allow you to perform different operations.
   Arithmetic operators
   Relational operators
   Logical operators
   Assignment operators
   Bitwise operators
   Special operators
Arithmetic Operator
   Arithmetic operators are binary operators, as they
    perform basic arithmetic operator on two operand.
Increment and decrement operators
   The increment operator (++) increases the value
    by 1, while the decrement operator(--) decreases
    the value by 1.
Relational Operators
   Relational operators are binary operators that make compare
    between two operands. They return a boolean value
    namely, true or false.
Logical Operators
   Logical operators are binary operators that perform logical
    operations on two operands.
Assignment Operators
 Assignmentoperator performs operations between the two
operands and assign the result to its left operand.
Bitwise Operators
Bitwise operators perform operations on the corresponding
individual bits of two operands.
Special Operators
•There are some operators in Javascript, which do not
belong to any of the categories of JavaScript operators
String Operators
Can merge two string values that are assigned to
two different variables.

  Operator         Descriptin                 Example
  +                Concatenates two or        var fullname=‘John’ + ‘ ’ +
                   more strings into a        ‘Blake’;
                   single string              fullname=‘John Blake’
  +=               Concatenates to or         var flower=‘Rose’;
  (Add-By-Value)   more strings and           flower +=‘’ + ‘flower’;
                   assign the result to its   flower =‘Rose Flower’;
                   left operant
Shift Operators
Shift operators are binary bitwise operators that perform shift operations on
bits. The first operand is the decimal number on which the shift operation is
performed. The second operand specifies the number or bit positions by
which the bits are to be shifted.
 Operator       Description                     Example
 <<             Shift the bit positions         8<<2 yield 32,because 00001000
 (Left Shift    towards the left by shifting    shifted by 2 bits becomes
 Operator)      the number of bits in the       00100000,which is 32. Here, the
                left at the right               two leftmost bits are placed toward
                                                the right
 >>             Shift the bit positions         8>>2 yield 32,because 00001000
 (Right Shift   towards the right by shifting   shifted by 2 bits becomes
 Operator)      the number of bits in the       00000010,which is 2. Here, the
                right at the left               two rightmost bits are placed
                                                toward the left.
Decision – making Statement
Decision-making statement s allow implementing logical
decision for executing different block to obtain the desired
output. They execute a block of statements depending upon a
boolean condition.
This condition is an expression that returns either true or
false.
Javascript supports four decision-making statements :
    If
    If-else
    If-else if else
    switch
The “if” Statement
The if statement executes a block of
statements based on a logical boolean
condition.
The “if-else” Statement
The if statement specifies a block of
statement to be executed when the
condition in the if statement is true, and
it’s requires to define a block of
statements to be executed when a
conditions evaluated to false
The “if-else if ” Statement
The if-else if statements allow you
to check multiple conditions and
specify a different block to be
execute for each condition.
Nested “if” Statement
The nested if statements comprises of
multiple if statements within an if
statement.
“Switch-case” Statement
To simplify the coding and avoid using multiple if
statement, switch-case statement can be used as a
different approach to code the same logic
Regular Expressions
 A regular expression is a pattern, whose purpose is to help in
validating the text format
 Example:
Types
Character or symbols allow matching a substring that exists at
a specific position within a string.
Types
Characters or symbols are combined to form character classes for
specifying patterns.
Summary
The & operator perform bitwise AND operation and
returns the result to the operand on the left hand side
The | operator performs bitwise OR operation and
returns the result to the operand on the left hand side
The ^ operator performs bitwise XOR operation and
returns the result to the operand on the left hand side
The string concatenation operator combine different
strings into single string.
Summary…
   The left shift operator shifts the bits on the
    leftmost side toward the right.
   The right shift operator shifts the bits on the
    rightmost side toward the left.
   Nested switch-case construct refers to including
    a switch-case construct within a case block.



                                  Building Dynamic Websites/Session 1/ 23 of 16

More Related Content

DOCX
Data types and operators in vb
PPTX
ODP
operators in c++
PPTX
Fundamental programming structures in java
PPTX
Operators , Functions and Options in VB.NET
PPTX
PPTX
Operators & Casts
PPTX
Vb script final pari
Data types and operators in vb
operators in c++
Fundamental programming structures in java
Operators , Functions and Options in VB.NET
Operators & Casts
Vb script final pari

What's hot (18)

PPTX
Operators and Expressions in Java
PDF
Chapter 13.1.2
PPTX
Operators in java
PPT
PDF
Js ch-1
DOCX
C# language basics (Visual studio)
PPT
PDF
itft-Operators in java
PPTX
Operators in java presentation
PPTX
Variable, constant, operators and control statement
PPTX
OCA JAVA - 3 Programming with Java Operators
PDF
Transformation of Classical Fractals applying Fractional Operators
PPTX
Operators in java
PDF
Operators in java
PPTX
Operators used in vb.net
PDF
Covariance and contravariance. Say what?! (Agile Talks #22)
PPTX
05 operators
PDF
Java basic operators
Operators and Expressions in Java
Chapter 13.1.2
Operators in java
Js ch-1
C# language basics (Visual studio)
itft-Operators in java
Operators in java presentation
Variable, constant, operators and control statement
OCA JAVA - 3 Programming with Java Operators
Transformation of Classical Fractals applying Fractional Operators
Operators in java
Operators in java
Operators used in vb.net
Covariance and contravariance. Say what?! (Agile Talks #22)
05 operators
Java basic operators
Ad

Viewers also liked (16)

PPTX
12. session 12 java script objects
PPTX
15. session 15 data binding
PPTX
10. session 10 loops and arrays
PPTX
11. session 11 functions and objects
PPT
08. session 08 intoduction to javascript
PPSX
Short notes of oop with java
PPT
07. session 07 adv css properties
PDF
Java Course 3: OOP
PPT
OOP in Java
PPTX
13. session 13 introduction to dhtml
PPT
Java OOP s concepts and buzzwords
PPT
Basic concepts of object oriented programming
PPT
Object oriented programming (oop) cs304 power point slides lecture 01
PPT
Object-oriented concepts
PPT
Object Oriented Programming Concepts
KEY
Practical OOP In Java
12. session 12 java script objects
15. session 15 data binding
10. session 10 loops and arrays
11. session 11 functions and objects
08. session 08 intoduction to javascript
Short notes of oop with java
07. session 07 adv css properties
Java Course 3: OOP
OOP in Java
13. session 13 introduction to dhtml
Java OOP s concepts and buzzwords
Basic concepts of object oriented programming
Object oriented programming (oop) cs304 power point slides lecture 01
Object-oriented concepts
Object Oriented Programming Concepts
Practical OOP In Java
Ad

Similar to 09. session 9 operators and statements (20)

PPT
Java - Operators
PPTX
Operators expressions-and-statements
PDF
07 ruby operators
PPTX
Operator 04 (js)
PPTX
Java script session 4
PPT
JavaScript Operators
PDF
JavaScript - Chapter 5 - Operators
PPTX
Introduction to JavaScript Scripting Language
PDF
JavaScript for beginners
PPTX
Operator in c programming
PPTX
Session03 operators
PDF
C sharp chap3
PPTX
Introduction to Client-Side Javascript
PPTX
03. Operators Expressions and statements
PPTX
Java Operators with Simple introduction.pptx
DOC
Report on c
PPT
3.OPERATORS_MB.ppt .
PPTX
Operators in C & C++ Language
PPT
9 cm604.10
PPS
Aae oop xp_04
Java - Operators
Operators expressions-and-statements
07 ruby operators
Operator 04 (js)
Java script session 4
JavaScript Operators
JavaScript - Chapter 5 - Operators
Introduction to JavaScript Scripting Language
JavaScript for beginners
Operator in c programming
Session03 operators
C sharp chap3
Introduction to Client-Side Javascript
03. Operators Expressions and statements
Java Operators with Simple introduction.pptx
Report on c
3.OPERATORS_MB.ppt .
Operators in C & C++ Language
9 cm604.10
Aae oop xp_04

More from Phúc Đỗ (8)

PPTX
15. session 15 data binding
PPTX
14. session 14 dhtml filter
PPTX
06. session 06 css color_andlayoutpropeties
PPTX
05. session 05 introducing css
PPTX
04. session 04 working withformsandframes
PPT
03. session 03 using lists and tables
PPT
02. session 02 working with html elements
PPT
01. session 01 introduction to html
15. session 15 data binding
14. session 14 dhtml filter
06. session 06 css color_andlayoutpropeties
05. session 05 introducing css
04. session 04 working withformsandframes
03. session 03 using lists and tables
02. session 02 working with html elements
01. session 01 introduction to html

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
KodekX | Application Modernization Development
PPTX
Cloud computing and distributed systems.
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Spectroscopy.pptx food analysis technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Approach and Philosophy of On baking technology
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Empathic Computing: Creating Shared Understanding
Unlocking AI with Model Context Protocol (MCP)
Spectral efficient network and resource selection model in 5G networks
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Per capita expenditure prediction using model stacking based on satellite ima...
KodekX | Application Modernization Development
Cloud computing and distributed systems.
Building Integrated photovoltaic BIPV_UPV.pdf
Machine learning based COVID-19 study performance prediction
Dropbox Q2 2025 Financial Results & Investor Presentation
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Spectroscopy.pptx food analysis technology
Review of recent advances in non-invasive hemoglobin estimation
Advanced methodologies resolving dimensionality complications for autism neur...
Approach and Philosophy of On baking technology
20250228 LYD VKU AI Blended-Learning.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Mobile App Security Testing_ A Comprehensive Guide.pdf
Empathic Computing: Creating Shared Understanding

09. session 9 operators and statements

  • 2. Objectives  Describe assignment operators  Explain bitwise operators  Explain switch-case statement  Describe regular expression
  • 3. Types of Operators  Operators help in simplifying expressions.  JavaScript provides a predefined set of operators that allow you to perform different operations.  Arithmetic operators  Relational operators  Logical operators  Assignment operators  Bitwise operators  Special operators
  • 4. Arithmetic Operator  Arithmetic operators are binary operators, as they perform basic arithmetic operator on two operand.
  • 5. Increment and decrement operators  The increment operator (++) increases the value by 1, while the decrement operator(--) decreases the value by 1.
  • 6. Relational Operators  Relational operators are binary operators that make compare between two operands. They return a boolean value namely, true or false.
  • 7. Logical Operators  Logical operators are binary operators that perform logical operations on two operands.
  • 8. Assignment Operators  Assignmentoperator performs operations between the two operands and assign the result to its left operand.
  • 9. Bitwise Operators Bitwise operators perform operations on the corresponding individual bits of two operands.
  • 10. Special Operators •There are some operators in Javascript, which do not belong to any of the categories of JavaScript operators
  • 11. String Operators Can merge two string values that are assigned to two different variables. Operator Descriptin Example + Concatenates two or var fullname=‘John’ + ‘ ’ + more strings into a ‘Blake’; single string fullname=‘John Blake’ += Concatenates to or var flower=‘Rose’; (Add-By-Value) more strings and flower +=‘’ + ‘flower’; assign the result to its flower =‘Rose Flower’; left operant
  • 12. Shift Operators Shift operators are binary bitwise operators that perform shift operations on bits. The first operand is the decimal number on which the shift operation is performed. The second operand specifies the number or bit positions by which the bits are to be shifted. Operator Description Example << Shift the bit positions 8<<2 yield 32,because 00001000 (Left Shift towards the left by shifting shifted by 2 bits becomes Operator) the number of bits in the 00100000,which is 32. Here, the left at the right two leftmost bits are placed toward the right >> Shift the bit positions 8>>2 yield 32,because 00001000 (Right Shift towards the right by shifting shifted by 2 bits becomes Operator) the number of bits in the 00000010,which is 2. Here, the right at the left two rightmost bits are placed toward the left.
  • 13. Decision – making Statement Decision-making statement s allow implementing logical decision for executing different block to obtain the desired output. They execute a block of statements depending upon a boolean condition. This condition is an expression that returns either true or false. Javascript supports four decision-making statements : If If-else If-else if else switch
  • 14. The “if” Statement The if statement executes a block of statements based on a logical boolean condition.
  • 15. The “if-else” Statement The if statement specifies a block of statement to be executed when the condition in the if statement is true, and it’s requires to define a block of statements to be executed when a conditions evaluated to false
  • 16. The “if-else if ” Statement The if-else if statements allow you to check multiple conditions and specify a different block to be execute for each condition.
  • 17. Nested “if” Statement The nested if statements comprises of multiple if statements within an if statement.
  • 18. “Switch-case” Statement To simplify the coding and avoid using multiple if statement, switch-case statement can be used as a different approach to code the same logic
  • 19. Regular Expressions  A regular expression is a pattern, whose purpose is to help in validating the text format  Example:
  • 20. Types Character or symbols allow matching a substring that exists at a specific position within a string.
  • 21. Types Characters or symbols are combined to form character classes for specifying patterns.
  • 22. Summary The & operator perform bitwise AND operation and returns the result to the operand on the left hand side The | operator performs bitwise OR operation and returns the result to the operand on the left hand side The ^ operator performs bitwise XOR operation and returns the result to the operand on the left hand side The string concatenation operator combine different strings into single string.
  • 23. Summary…  The left shift operator shifts the bits on the leftmost side toward the right.  The right shift operator shifts the bits on the rightmost side toward the left.  Nested switch-case construct refers to including a switch-case construct within a case block. Building Dynamic Websites/Session 1/ 23 of 16