SlideShare a Scribd company logo
1 of 27
JavaScript Training
Goal Trainers Format
• Lecture
• Exercises
• Ask Questions!
• bitovi/js-training
=== and ==
21 == "21"
undefined == null
undefined === null
21 === 21
{} === {}
NaN === NaN
true == {valueOf: function(){return "1"}}
✓
✓
✓
✓
❌
❌
❌
Address Value
…. ….
x1001 call-object
x1002 str1
x1003 x2001
x1004 str2
x1005 x2101
…. ….
x2001 STRING
x2002 hi
…. ….
x2101 STRING
x2102 hi
=== with primitives
var str1 = "hi";
var str2 = "hi";
str1 === str2
✓
var obj1 = {};
var obj2 = {};
obj1 === obj2
❌
Address Value
…. ….
x1001 call-object
x1002 obj1
x1003 x2001
x1004 obj2
x1005 x2101
…. ….
x2001 OBJECT
x2002 0
…. ….
x2101 OBJECT
x2102 0
=== with objects
Types the same?
x==y
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
==
string== number?
boolean == anything
Types the same?
true==({toString: function(){return "1"}})
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
==
string== number?
boolean == anything
true==({toString: function(){return "1"}})
Types the same?
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
==
string== number?
boolean == anything
true==({toString: function(){return "1"}})
Types the same?
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
==
string== number?
boolean == anything
true==({toString: function(){return "1"}})
Types the same?
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
==
string== number?
boolean == anything
true==({toString: function(){return "1"}})
Types the same?
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
==
string== number?
boolean == anything
true==({toString: function(){return "1"}})
Types the same?
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
==
string== number?
boolean == anything
true==({toString: function(){return "1"}})
Types the same?
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
string== number?
boolean == anything
1 == ({toString:function(){return"1"}})
Types the same?
1==({toString: function(){return "1"}})
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
==
string== number?
boolean == anything
Types the same?
1==({toString: function(){return "1"}})
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
==
string== number?
boolean == anything
Types the same?
1==({toString: function(){return "1"}})
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
==
string== number?
boolean == anything
Types the same?
1==({toString: function(){return "1"}})
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
==
string== number?
boolean == anything
Types the same?
1==({toString: function(){return "1"}})
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
==
string== number?
boolean == anything
Types the same?
1==({toString: function(){return "1"}})
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
==
string== number?
boolean == anything
Types the same?
1==({toString: function(){return "1"}})
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
string== number?
boolean == anything
1=="1"
Types the same?
1 == "1"
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
==
string== number?
boolean == anything
Types the same?
1 == "1"
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
==
string== number?
boolean == anything
Types the same?
1 == "1"
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
==
string== number?
boolean == anything
Types the same?
1 == "1"
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
==
string== number?
boolean == anything
Types the same?
1 == "1"
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
string== number?
boolean == anything
1==1
Types the same?
1 == 1
Both null or undefined?
object == string or number?
undefined -> NaN
null -> 0
true -> 1
false -> 0
string -> # || NaN
.toString()
.valueOf()
===
true
false
==
==
string== number?
boolean == anything
Summary
type coercion craziness
primitive?
bitwise comparison address comparison
===
==
Types the same?
false

More Related Content

What's hot

Traversals for all ocasions
Traversals for all ocasionsTraversals for all ocasions
Traversals for all ocasionsLuka Jacobowitz
 
Day 7 evaluating all integers
Day 7 evaluating all integersDay 7 evaluating all integers
Day 7 evaluating all integersErik Tjersland
 
Dataclasses en Python 3.7: Empieza a borrar código
Dataclasses en Python 3.7: Empieza a borrar códigoDataclasses en Python 3.7: Empieza a borrar código
Dataclasses en Python 3.7: Empieza a borrar códigoJacobo de Vera
 
Monoids, Monoids, Monoids - ScalaLove 2020
Monoids, Monoids, Monoids - ScalaLove 2020Monoids, Monoids, Monoids - ScalaLove 2020
Monoids, Monoids, Monoids - ScalaLove 2020Luka Jacobowitz
 
LeetCode April Coding Challenge
LeetCode April Coding ChallengeLeetCode April Coding Challenge
LeetCode April Coding ChallengeSunil Yadav
 
Functional Programming in Swift
Functional Programming in SwiftFunctional Programming in Swift
Functional Programming in SwiftSaugat Gautam
 
2 5math Laws
2 5math Laws2 5math Laws
2 5math Lawstaco40
 
Integers slidecast
Integers slidecastIntegers slidecast
Integers slidecastmillergjtime
 
[1062BPY12001] Data analysis with R / week 3
[1062BPY12001] Data analysis with R / week 3[1062BPY12001] Data analysis with R / week 3
[1062BPY12001] Data analysis with R / week 3Kevin Chun-Hsien Hsu
 
Print input-presentation
Print input-presentationPrint input-presentation
Print input-presentationMartin McBride
 
The Ring programming language version 1.10 book - Part 27 of 212
The Ring programming language version 1.10 book - Part 27 of 212The Ring programming language version 1.10 book - Part 27 of 212
The Ring programming language version 1.10 book - Part 27 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 15 of 88
The Ring programming language version 1.3 book - Part 15 of 88The Ring programming language version 1.3 book - Part 15 of 88
The Ring programming language version 1.3 book - Part 15 of 88Mahmoud Samir Fayed
 
Properties of addition and multiplication
Properties of addition and multiplicationProperties of addition and multiplication
Properties of addition and multiplicationShiara Agosto
 
Get started with Reason
Get started with ReasonGet started with Reason
Get started with ReasonNikolaus Graf
 

What's hot (19)

Traversals for all ocasions
Traversals for all ocasionsTraversals for all ocasions
Traversals for all ocasions
 
Day 7 evaluating all integers
Day 7 evaluating all integersDay 7 evaluating all integers
Day 7 evaluating all integers
 
Dataclasses en Python 3.7: Empieza a borrar código
Dataclasses en Python 3.7: Empieza a borrar códigoDataclasses en Python 3.7: Empieza a borrar código
Dataclasses en Python 3.7: Empieza a borrar código
 
Lecture 6 python oop (ewurc)
Lecture 6 python oop (ewurc)Lecture 6 python oop (ewurc)
Lecture 6 python oop (ewurc)
 
2-1 Properties of Addition
2-1 Properties of Addition2-1 Properties of Addition
2-1 Properties of Addition
 
Monoids, Monoids, Monoids - ScalaLove 2020
Monoids, Monoids, Monoids - ScalaLove 2020Monoids, Monoids, Monoids - ScalaLove 2020
Monoids, Monoids, Monoids - ScalaLove 2020
 
LeetCode April Coding Challenge
LeetCode April Coding ChallengeLeetCode April Coding Challenge
LeetCode April Coding Challenge
 
AM2 MATLAB
AM2 MATLABAM2 MATLAB
AM2 MATLAB
 
Functional Programming in Swift
Functional Programming in SwiftFunctional Programming in Swift
Functional Programming in Swift
 
2 5math Laws
2 5math Laws2 5math Laws
2 5math Laws
 
Python programming : Standard Input and Output
Python programming : Standard Input and OutputPython programming : Standard Input and Output
Python programming : Standard Input and Output
 
Integers slidecast
Integers slidecastIntegers slidecast
Integers slidecast
 
2D array
2D array2D array
2D array
 
[1062BPY12001] Data analysis with R / week 3
[1062BPY12001] Data analysis with R / week 3[1062BPY12001] Data analysis with R / week 3
[1062BPY12001] Data analysis with R / week 3
 
Print input-presentation
Print input-presentationPrint input-presentation
Print input-presentation
 
The Ring programming language version 1.10 book - Part 27 of 212
The Ring programming language version 1.10 book - Part 27 of 212The Ring programming language version 1.10 book - Part 27 of 212
The Ring programming language version 1.10 book - Part 27 of 212
 
The Ring programming language version 1.3 book - Part 15 of 88
The Ring programming language version 1.3 book - Part 15 of 88The Ring programming language version 1.3 book - Part 15 of 88
The Ring programming language version 1.3 book - Part 15 of 88
 
Properties of addition and multiplication
Properties of addition and multiplicationProperties of addition and multiplication
Properties of addition and multiplication
 
Get started with Reason
Get started with ReasonGet started with Reason
Get started with Reason
 

Viewers also liked

Viewers also liked (7)

Closures
ClosuresClosures
Closures
 
Types, Operators and Primitives
Types, Operators and PrimitivesTypes, Operators and Primitives
Types, Operators and Primitives
 
Prototypes
PrototypesPrototypes
Prototypes
 
Element Styles and Positioning
Element Styles and PositioningElement Styles and Positioning
Element Styles and Positioning
 
Context
ContextContext
Context
 
Events - Part 2
Events - Part 2Events - Part 2
Events - Part 2
 
Basic JS
Basic JSBasic JS
Basic JS
 

Similar to Comparisons

Functional Programming with Groovy
Functional Programming with GroovyFunctional Programming with Groovy
Functional Programming with GroovyArturo Herrero
 
Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)intelliyole
 
Perl 6 in Context
Perl 6 in ContextPerl 6 in Context
Perl 6 in Contextlichtkind
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlinintelliyole
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kirill Rozov
 
A swift introduction to Swift
A swift introduction to SwiftA swift introduction to Swift
A swift introduction to SwiftGiordano Scalzo
 
Swift에서 꼬리재귀 사용기 (Tail Recursion)
Swift에서 꼬리재귀 사용기 (Tail Recursion)Swift에서 꼬리재귀 사용기 (Tail Recursion)
Swift에서 꼬리재귀 사용기 (Tail Recursion)진성 오
 
2.4 multiplication of real numbers 1
2.4 multiplication of real numbers 12.4 multiplication of real numbers 1
2.4 multiplication of real numbers 1bweldon
 
Monadologie
MonadologieMonadologie
Monadologieleague
 
Functional programming with clojure
Functional programming with clojureFunctional programming with clojure
Functional programming with clojureLucy Fang
 
A limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced RubyA limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced RubyVysakh Sreenivasan
 

Similar to Comparisons (20)

Functional Programming with Groovy
Functional Programming with GroovyFunctional Programming with Groovy
Functional Programming with Groovy
 
Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)
 
FYP Final Presentation
FYP Final PresentationFYP Final Presentation
FYP Final Presentation
 
Perl 6 in Context
Perl 6 in ContextPerl 6 in Context
Perl 6 in Context
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlin
 
Benefits of Kotlin
Benefits of KotlinBenefits of Kotlin
Benefits of Kotlin
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2
 
Pooya Khaloo Presentation on IWMC 2015
Pooya Khaloo Presentation on IWMC 2015Pooya Khaloo Presentation on IWMC 2015
Pooya Khaloo Presentation on IWMC 2015
 
A swift introduction to Swift
A swift introduction to SwiftA swift introduction to Swift
A swift introduction to Swift
 
Números Reales - Genesis Sira
Números Reales - Genesis SiraNúmeros Reales - Genesis Sira
Números Reales - Genesis Sira
 
Swift에서 꼬리재귀 사용기 (Tail Recursion)
Swift에서 꼬리재귀 사용기 (Tail Recursion)Swift에서 꼬리재귀 사용기 (Tail Recursion)
Swift에서 꼬리재귀 사용기 (Tail Recursion)
 
Swift School #1
Swift School #1Swift School #1
Swift School #1
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
2.4 multiplication of real numbers 1
2.4 multiplication of real numbers 12.4 multiplication of real numbers 1
2.4 multiplication of real numbers 1
 
Monadologie
MonadologieMonadologie
Monadologie
 
Scala taxonomy
Scala taxonomyScala taxonomy
Scala taxonomy
 
Functional programming with clojure
Functional programming with clojureFunctional programming with clojure
Functional programming with clojure
 
A limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced RubyA limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced Ruby
 
Short intro to ECMAScript
Short intro to ECMAScriptShort intro to ECMAScript
Short intro to ECMAScript
 
Fp
FpFp
Fp
 

Recently uploaded

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 

Recently uploaded (20)

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 

Comparisons

  • 1. JavaScript Training Goal Trainers Format • Lecture • Exercises • Ask Questions! • bitovi/js-training
  • 3. 21 == "21" undefined == null undefined === null 21 === 21 {} === {} NaN === NaN true == {valueOf: function(){return "1"}} ✓ ✓ ✓ ✓ ❌ ❌ ❌
  • 4. Address Value …. …. x1001 call-object x1002 str1 x1003 x2001 x1004 str2 x1005 x2101 …. …. x2001 STRING x2002 hi …. …. x2101 STRING x2102 hi === with primitives var str1 = "hi"; var str2 = "hi"; str1 === str2 ✓
  • 5. var obj1 = {}; var obj2 = {}; obj1 === obj2 ❌ Address Value …. …. x1001 call-object x1002 obj1 x1003 x2001 x1004 obj2 x1005 x2101 …. …. x2001 OBJECT x2002 0 …. …. x2101 OBJECT x2102 0 === with objects
  • 6. Types the same? x==y Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == == string== number? boolean == anything
  • 7. Types the same? true==({toString: function(){return "1"}}) Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == == string== number? boolean == anything
  • 8. true==({toString: function(){return "1"}}) Types the same? Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == == string== number? boolean == anything
  • 9. true==({toString: function(){return "1"}}) Types the same? Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == == string== number? boolean == anything
  • 10. true==({toString: function(){return "1"}}) Types the same? Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == == string== number? boolean == anything
  • 11. true==({toString: function(){return "1"}}) Types the same? Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == == string== number? boolean == anything
  • 12. true==({toString: function(){return "1"}}) Types the same? Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == == string== number? boolean == anything
  • 13. true==({toString: function(){return "1"}}) Types the same? Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == string== number? boolean == anything 1 == ({toString:function(){return"1"}})
  • 14. Types the same? 1==({toString: function(){return "1"}}) Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == == string== number? boolean == anything
  • 15. Types the same? 1==({toString: function(){return "1"}}) Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == == string== number? boolean == anything
  • 16. Types the same? 1==({toString: function(){return "1"}}) Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == == string== number? boolean == anything
  • 17. Types the same? 1==({toString: function(){return "1"}}) Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == == string== number? boolean == anything
  • 18. Types the same? 1==({toString: function(){return "1"}}) Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == == string== number? boolean == anything
  • 19. Types the same? 1==({toString: function(){return "1"}}) Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == == string== number? boolean == anything
  • 20. Types the same? 1==({toString: function(){return "1"}}) Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == string== number? boolean == anything 1=="1"
  • 21. Types the same? 1 == "1" Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == == string== number? boolean == anything
  • 22. Types the same? 1 == "1" Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == == string== number? boolean == anything
  • 23. Types the same? 1 == "1" Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == == string== number? boolean == anything
  • 24. Types the same? 1 == "1" Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == == string== number? boolean == anything
  • 25. Types the same? 1 == "1" Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == string== number? boolean == anything 1==1
  • 26. Types the same? 1 == 1 Both null or undefined? object == string or number? undefined -> NaN null -> 0 true -> 1 false -> 0 string -> # || NaN .toString() .valueOf() === true false == == string== number? boolean == anything
  • 27. Summary type coercion craziness primitive? bitwise comparison address comparison === == Types the same? false

Editor's Notes

  1. I think the key to JavaScript is really understanding what’s going on in memory. And the key to understanding what’s going on in memory is understanding what JS’s basic data types look like in memory and how JS’s operators are used to manipulate those data structures.
  2. Here I’ve created an object with an age property of 30. I create a variable to hold that person’s age and update it to 31, but if I read me.age, I get back 30 .. why?