The 'while' loop/? about === and =


#1


https://www.codecademy.com/courses/javascript-beginner-en-mrTNH-6VIZ9/0/3?curriculum_id=506324b3a7dffd00020bf661

I know that === and = is different but fromt he examples below how come the second one won't work?


while(slaying===true){
    slaying = false;
    }

while(slaying === true){
     slaying === false;
}


#2

@jaelee45,

The = is the so-called assignment operator
with which you assign a Value to a variable
like
slaying = false;

In Javascript you have 2 equality operators

  • the == is the so-called equality operator with =type conversion=
    • 0 == false gives a true
      "0" == 0 gives a true
  • the === the so-called strict equality operator
    the left and right argument must both be of the SAME data-type

    • 0 === false gives a false
      "0" === 0 gives a false

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators

Nice to know

Possible data types

The **VALUE** can be anything from:

•Number
•String
•Boolean
•Symbol
•Object  ◦Function
         ◦Array
         ◦Date
         ◦RegExp
         ◦Math
•Null
•Undefined