Javascript
/
Fundamentals
- 1 Fundamentals 11
-
Hello World
-
Code structure
-
Use strict
-
Variables
-
Data types
-
Type conversions
-
Maths
-
Comparitions
-
Conditional
-
Loops
-
Functions
- 2 Testing 2
-
Mocha
-
Nested describe
- 3 Objects 4
-
Basics
-
Reference
-
Methods
-
Constructor
- 4 Types 5
-
Primitives
-
Numbers
-
Strings
-
Arrays
-
Json
- 5 Classes 3
-
Constructor
-
Binding
-
Inheritance
/
Comparitions
➟
➟
Last update: 17-01-2022
Boolean
All comparitions operators return a boolean value.
/**
* A comparition result can be assign to a variable,
* like any other value.
*/
console.log(2 > 1); // true
console.log(2 == 1); //false
let result = 2 > 1;
console.log(result); // true
Strict
! The strict equality operator leaves less room for errors.
/**
* When comparing different types Javascript ...
* converts the values to numbers.
*
* A strict equality operator ====
* checks the equality without type conversion
*/
console.assert( '2' > 1 ); // pass (Wrong)
console.assert( '01' == 1 ); // pass (Wrong)
console.assert( '01' === 1 ); // failed (Correct)
➥ Questions github Fundamentals