SlideShare une entreprise Scribd logo
1  sur  27
JavaScript
Operators
Charles Russell
Bennu Bird Media
What is an Operator
●
An Operator is a function with different syntax
●
Operators performs some action and returns a value
●
The values being acted upon are called operands
●
The value returned is the result
●
Operands may be literals, variables, or expressions
●
They are used to make expressions
Operators can be
catagorized by size
●
An expression can consist of many operators but
when broken down to each operation idvidually,
there are three sizes
●
A unary operator is an operator on a single value
– The – sign makes a number negative
●
A binary operator is an operator works with two values
– Your normal addition, subtraction, multiplication and division
●
Ternary Operator that takes three values
The + Operator
●
It is both a unary and binary operator
●
Unary operation, + on a line in front of a variable
and it makes that variable a number.
●
It tries to make sense of the operand. This is called
coercion If the string contains only digits then you get
the value contained in the string, a boolean returns 1
for true 0 for false
●
If it can not make a number that makes sense a NaN
is returned ex: any letters in the string
The + operator in binary
mode
●
Numbers is not all this operator works on
●
This is also the concatenation operator for strings.
●
The various combinations of number and string
resolve to different data types with this language
●
number + number = number
●
string + string = string
●
string + number = string
●
Number () or String() to type cast as needed.
Subtraction or Minus
●
The – operator is again both binary and unary
●
Returns a number no matter the mode
●
A-B
●
The – operator returns A reduced by the value of B
– If the operands can be logically turned to numbers the result
will be the value of the operations otherwise you get NaN
The – operator in Unary
mode
For numeric value changes the sign (pos to neg)
(neg to pos)
●
Tries to make a number out of other data types
Introducing the increment
●
++ unary operator that adds 1 to the current value
●
Pre increment post increment.
●
Although in the end the variable is incremented the
side of the variable you are incrementing that you put
the operater on matters
●
If the operator comes before the variable (pre
increment) the operation occures then assignment
●
If the operator comes second assignment happens
then the increment
●
Strings will try to be converted to numbers non
numeric strings will return NaN
Decrement
●
If there is an increment operator then logically
there must be a decrement operator
●
As you would suspect - -
●
Behaves in a simular fashion to ++
Multiplication
●
*
●
Binary operator
●
Returns NaN if an operand is a non numeric string
Division
●
/
●
Binary operator
●
Behaves in a simular fashion to Multiplication
Modulus
●
%
●
Binary operator
●
Does integer divsion and returns the remainder
●
Again type conversion is attempted
Assignment
●
=
●
Assigns a value to a variable
●
Lvalue assigned to rvalue
●
Not a check for equality that is another operator
●
X=5 Works fine
●
5=5 'X' = 5 or 'X' = 'X' results in a reference error
The Rest of the
Assignment Family
●
+=, -=, *=, %=
●
These operators do a calculation and assign the
value simutaneously
●
Example
●
A=5; A+=3
– Result 8
Comparison
●
These return a boolean
●
Equality ==
●
Super Equality ===
●
Inequality !=
●
Super Inequality !==
●
Less than <
●
Less than or Equal <=
●
Greater Than >
●
Greater than or Equal to >=
Next: More Operators
JavaScript
Operators part2
Charles Russell
Bennu Bird Media
Whats the truth
●
I'm not strange, weird, off, nor crazy, my reality is
just different from yours (Lewis Carol)
●
You would expect && and || to return boolean but
it may or may not
●
Shortcut evaluation
– Evaluation of is done from left to right value returned as
soon as evaluation can be made
– Remember truthy and falsey
●
The truthy or falseyness of any value can be determined
●
This means that a value that is not boolean can be returned and the
truthynesss or falsyness of the expression can be evaluated.
And &&
●
A && B
●
True Only if both opeands are true
●
If A falsey then B returned Data Type unchanged
●
Used to Gaurd B
A B Result
T T B
T F B
F F A
F T A
Or ||
●
A || B
●
If A False B is returned data type unchanged
●
True if A truthy or B Truthy
●
Very useful to check if a value is set
A B Result
T T A
T F A
F T B
F T B
Not !
●
Reverses a Boolean value
Bit opeations
●
& bitwise and
●
| bitwise or
●
^ bitwise xor
●
~ bitwise not
●
<< shift left
●
>> shift right
●
>>> shift right zero fill
Bit twiddling used to
something to avoid
●
This was the convential wisdom.
●
While this improved effiency in other languages in this
one performance degraded
●
This seems to be changing
●
http://dreaminginjavascript.wordpress.com/2009/02/09/bi
●
What you can do with this
●
http://michalbe.blogspot.com/2013/03/javascript-less-kno
●
http://graphics.stanford.edu/~seander/bithacks.html
The conditional operator
●
This is the tenary operator and it roughly equates
to if operand 1 then operand 2 else operand 3
●
Operand1 ? Operand2 : Operand3
●
Operand 1 is the boolean if true
– Do the action specified in Operand 2
●
Else do the action in specified operand 3
Grouping
●
()
●
Groups expressions that need to be evaluated
first
Yes there are others
●
I am not mentioning some operators here
because many of these not mentioned apply to
functions, arrays and Objects topics yet to be
covered these other operaterators will be
introduced and disscussed when and if
appropriate
Operator Precedence
[] ()
++ -- - ~ !
* / %
+ - +
<< >> >>>
< <= > >=
== != === !==
&
^
|
&&
||
? :
= += -= *= ...

Contenu connexe

Tendances

Ruby Functional Programming
Ruby Functional ProgrammingRuby Functional Programming
Ruby Functional ProgrammingGeison Goes
 
Type conversions
Type conversionsType conversions
Type conversionssanya6900
 
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD? WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD? reactima
 
Functional JavaScript Fundamentals
Functional JavaScript FundamentalsFunctional JavaScript Fundamentals
Functional JavaScript FundamentalsSrdjan Strbanovic
 
Functional Programming in JavaScript by Luis Atencio
Functional Programming in JavaScript by Luis AtencioFunctional Programming in JavaScript by Luis Atencio
Functional Programming in JavaScript by Luis AtencioLuis Atencio
 
Angular 2.0: Brighter future?
Angular 2.0: Brighter future?Angular 2.0: Brighter future?
Angular 2.0: Brighter future?Eugene Zharkov
 
LC2018 - Input Validation in PureScript
LC2018 - Input Validation in PureScriptLC2018 - Input Validation in PureScript
LC2018 - Input Validation in PureScriptJoe Kachmar
 
Intro to JavaScript - Week 2: Function
Intro to JavaScript - Week 2: FunctionIntro to JavaScript - Week 2: Function
Intro to JavaScript - Week 2: FunctionJeongbae Oh
 
JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript FunctionsColin DeCarlo
 
Functional programming and ruby in functional style
Functional programming and ruby in functional styleFunctional programming and ruby in functional style
Functional programming and ruby in functional styleNiranjan Sarade
 
C++ overloading
C++ overloadingC++ overloading
C++ overloadingsanya6900
 
2CPP03 - Object Orientation Fundamentals
2CPP03 - Object Orientation Fundamentals2CPP03 - Object Orientation Fundamentals
2CPP03 - Object Orientation FundamentalsMichael Heron
 
Introduction to Object Oriented Javascript
Introduction to Object Oriented JavascriptIntroduction to Object Oriented Javascript
Introduction to Object Oriented Javascriptnodeninjas
 
Reactive Programming with JavaScript
Reactive Programming with JavaScriptReactive Programming with JavaScript
Reactive Programming with JavaScriptCodemotion
 
Operator overloading
Operator overloadingOperator overloading
Operator overloadingArunaDevi63
 
Presentation on overloading
Presentation on overloading Presentation on overloading
Presentation on overloading Charndeep Sekhon
 

Tendances (20)

Client sidescripting javascript
Client sidescripting javascriptClient sidescripting javascript
Client sidescripting javascript
 
Ruby Functional Programming
Ruby Functional ProgrammingRuby Functional Programming
Ruby Functional Programming
 
Scala - core features
Scala - core featuresScala - core features
Scala - core features
 
Type conversions
Type conversionsType conversions
Type conversions
 
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD? WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
 
Functional JavaScript Fundamentals
Functional JavaScript FundamentalsFunctional JavaScript Fundamentals
Functional JavaScript Fundamentals
 
Functional Programming in JavaScript by Luis Atencio
Functional Programming in JavaScript by Luis AtencioFunctional Programming in JavaScript by Luis Atencio
Functional Programming in JavaScript by Luis Atencio
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
Angular 2.0: Brighter future?
Angular 2.0: Brighter future?Angular 2.0: Brighter future?
Angular 2.0: Brighter future?
 
LC2018 - Input Validation in PureScript
LC2018 - Input Validation in PureScriptLC2018 - Input Validation in PureScript
LC2018 - Input Validation in PureScript
 
Intro to JavaScript - Week 2: Function
Intro to JavaScript - Week 2: FunctionIntro to JavaScript - Week 2: Function
Intro to JavaScript - Week 2: Function
 
JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript Functions
 
Functional programming and ruby in functional style
Functional programming and ruby in functional styleFunctional programming and ruby in functional style
Functional programming and ruby in functional style
 
C++ overloading
C++ overloadingC++ overloading
C++ overloading
 
2CPP03 - Object Orientation Fundamentals
2CPP03 - Object Orientation Fundamentals2CPP03 - Object Orientation Fundamentals
2CPP03 - Object Orientation Fundamentals
 
Let's JavaScript
Let's JavaScriptLet's JavaScript
Let's JavaScript
 
Introduction to Object Oriented Javascript
Introduction to Object Oriented JavascriptIntroduction to Object Oriented Javascript
Introduction to Object Oriented Javascript
 
Reactive Programming with JavaScript
Reactive Programming with JavaScriptReactive Programming with JavaScript
Reactive Programming with JavaScript
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Presentation on overloading
Presentation on overloading Presentation on overloading
Presentation on overloading
 

Similaire à JavaScript Operators (20)

Operators in java
Operators in javaOperators in java
Operators in java
 
Java script operators
Java script operatorsJava script operators
Java script operators
 
L3 operators
L3 operatorsL3 operators
L3 operators
 
L3 operators
L3 operatorsL3 operators
L3 operators
 
L3 operators
L3 operatorsL3 operators
L3 operators
 
C Sharp Jn (2)
C Sharp Jn (2)C Sharp Jn (2)
C Sharp Jn (2)
 
C Sharp Jn (2)
C Sharp Jn (2)C Sharp Jn (2)
C Sharp Jn (2)
 
Operators
OperatorsOperators
Operators
 
operators in c++
operators in c++operators in c++
operators in c++
 
operators in c++
operators in c++operators in c++
operators in c++
 
4_A1208223655_21789_2_2018_04. Operators.ppt
4_A1208223655_21789_2_2018_04. Operators.ppt4_A1208223655_21789_2_2018_04. Operators.ppt
4_A1208223655_21789_2_2018_04. Operators.ppt
 
OPERATORS OF C++
OPERATORS OF C++OPERATORS OF C++
OPERATORS OF C++
 
Operators
OperatorsOperators
Operators
 
C Operators
C OperatorsC Operators
C Operators
 
Unit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in cUnit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in c
 
Operators used in vb.net
Operators used in vb.netOperators used in vb.net
Operators used in vb.net
 
Types of Operators in C
Types of Operators in CTypes of Operators in C
Types of Operators in C
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
operator ppt.ppt
operator ppt.pptoperator ppt.ppt
operator ppt.ppt
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++
 

Plus de Charles Russell

JavaScript Introductin to Functions
JavaScript Introductin to FunctionsJavaScript Introductin to Functions
JavaScript Introductin to FunctionsCharles Russell
 
JavaScript Tools and Implementation
JavaScript Tools and ImplementationJavaScript Tools and Implementation
JavaScript Tools and ImplementationCharles Russell
 
JavaScript Comments and Conditionals
JavaScript Comments and ConditionalsJavaScript Comments and Conditionals
JavaScript Comments and ConditionalsCharles Russell
 
Extending drupal authentication
Extending drupal authenticationExtending drupal authentication
Extending drupal authenticationCharles Russell
 

Plus de Charles Russell (9)

Js objects
Js objectsJs objects
Js objects
 
JavaScript Introductin to Functions
JavaScript Introductin to FunctionsJavaScript Introductin to Functions
JavaScript Introductin to Functions
 
JavaScript iteration
JavaScript iterationJavaScript iteration
JavaScript iteration
 
Open Source Software
Open Source SoftwareOpen Source Software
Open Source Software
 
JavaScript Variables
JavaScript VariablesJavaScript Variables
JavaScript Variables
 
JavaScript Tools and Implementation
JavaScript Tools and ImplementationJavaScript Tools and Implementation
JavaScript Tools and Implementation
 
JavaScript Comments and Conditionals
JavaScript Comments and ConditionalsJavaScript Comments and Conditionals
JavaScript Comments and Conditionals
 
JavaScript Introduction
JavaScript IntroductionJavaScript Introduction
JavaScript Introduction
 
Extending drupal authentication
Extending drupal authenticationExtending drupal authentication
Extending drupal authentication
 

Dernier

₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...Diya Sharma
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024APNIC
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Servicegwenoracqe6
 
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.CarlotaBedoya1
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...tanu pandey
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...Neha Pandey
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$kojalkojal131
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.soniya singh
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...APNIC
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...singhpriety023
 

Dernier (20)

₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
 
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 

JavaScript Operators

  • 2. What is an Operator ● An Operator is a function with different syntax ● Operators performs some action and returns a value ● The values being acted upon are called operands ● The value returned is the result ● Operands may be literals, variables, or expressions ● They are used to make expressions
  • 3. Operators can be catagorized by size ● An expression can consist of many operators but when broken down to each operation idvidually, there are three sizes ● A unary operator is an operator on a single value – The – sign makes a number negative ● A binary operator is an operator works with two values – Your normal addition, subtraction, multiplication and division ● Ternary Operator that takes three values
  • 4. The + Operator ● It is both a unary and binary operator ● Unary operation, + on a line in front of a variable and it makes that variable a number. ● It tries to make sense of the operand. This is called coercion If the string contains only digits then you get the value contained in the string, a boolean returns 1 for true 0 for false ● If it can not make a number that makes sense a NaN is returned ex: any letters in the string
  • 5. The + operator in binary mode ● Numbers is not all this operator works on ● This is also the concatenation operator for strings. ● The various combinations of number and string resolve to different data types with this language ● number + number = number ● string + string = string ● string + number = string ● Number () or String() to type cast as needed.
  • 6. Subtraction or Minus ● The – operator is again both binary and unary ● Returns a number no matter the mode ● A-B ● The – operator returns A reduced by the value of B – If the operands can be logically turned to numbers the result will be the value of the operations otherwise you get NaN
  • 7. The – operator in Unary mode For numeric value changes the sign (pos to neg) (neg to pos) ● Tries to make a number out of other data types
  • 8. Introducing the increment ● ++ unary operator that adds 1 to the current value ● Pre increment post increment. ● Although in the end the variable is incremented the side of the variable you are incrementing that you put the operater on matters ● If the operator comes before the variable (pre increment) the operation occures then assignment ● If the operator comes second assignment happens then the increment ● Strings will try to be converted to numbers non numeric strings will return NaN
  • 9. Decrement ● If there is an increment operator then logically there must be a decrement operator ● As you would suspect - - ● Behaves in a simular fashion to ++
  • 10. Multiplication ● * ● Binary operator ● Returns NaN if an operand is a non numeric string
  • 11. Division ● / ● Binary operator ● Behaves in a simular fashion to Multiplication
  • 12. Modulus ● % ● Binary operator ● Does integer divsion and returns the remainder ● Again type conversion is attempted
  • 13. Assignment ● = ● Assigns a value to a variable ● Lvalue assigned to rvalue ● Not a check for equality that is another operator ● X=5 Works fine ● 5=5 'X' = 5 or 'X' = 'X' results in a reference error
  • 14. The Rest of the Assignment Family ● +=, -=, *=, %= ● These operators do a calculation and assign the value simutaneously ● Example ● A=5; A+=3 – Result 8
  • 15. Comparison ● These return a boolean ● Equality == ● Super Equality === ● Inequality != ● Super Inequality !== ● Less than < ● Less than or Equal <= ● Greater Than > ● Greater than or Equal to >=
  • 18. Whats the truth ● I'm not strange, weird, off, nor crazy, my reality is just different from yours (Lewis Carol) ● You would expect && and || to return boolean but it may or may not ● Shortcut evaluation – Evaluation of is done from left to right value returned as soon as evaluation can be made – Remember truthy and falsey ● The truthy or falseyness of any value can be determined ● This means that a value that is not boolean can be returned and the truthynesss or falsyness of the expression can be evaluated.
  • 19. And && ● A && B ● True Only if both opeands are true ● If A falsey then B returned Data Type unchanged ● Used to Gaurd B A B Result T T B T F B F F A F T A
  • 20. Or || ● A || B ● If A False B is returned data type unchanged ● True if A truthy or B Truthy ● Very useful to check if a value is set A B Result T T A T F A F T B F T B
  • 21. Not ! ● Reverses a Boolean value
  • 22. Bit opeations ● & bitwise and ● | bitwise or ● ^ bitwise xor ● ~ bitwise not ● << shift left ● >> shift right ● >>> shift right zero fill
  • 23. Bit twiddling used to something to avoid ● This was the convential wisdom. ● While this improved effiency in other languages in this one performance degraded ● This seems to be changing ● http://dreaminginjavascript.wordpress.com/2009/02/09/bi ● What you can do with this ● http://michalbe.blogspot.com/2013/03/javascript-less-kno ● http://graphics.stanford.edu/~seander/bithacks.html
  • 24. The conditional operator ● This is the tenary operator and it roughly equates to if operand 1 then operand 2 else operand 3 ● Operand1 ? Operand2 : Operand3 ● Operand 1 is the boolean if true – Do the action specified in Operand 2 ● Else do the action in specified operand 3
  • 25. Grouping ● () ● Groups expressions that need to be evaluated first
  • 26. Yes there are others ● I am not mentioning some operators here because many of these not mentioned apply to functions, arrays and Objects topics yet to be covered these other operaterators will be introduced and disscussed when and if appropriate
  • 27. Operator Precedence [] () ++ -- - ~ ! * / % + - + << >> >>> < <= > >= == != === !== & ^ | && || ? : = += -= *= ...