search

Home  >  Q&A  >  body text

aCopy === arr; Why is it false?

aCopy === arr; Why is it false?

They have the same value, but are their types different? Aren't they all array types?

自律者自由自律者自由2582 days ago1809

reply all(3)I'll reply

  • 有人@我

    有人@我2017-12-25 17:40:05

    There is no such thing as an array type. Arrays belong to objects. When judging, if you use ===, you can

    1. Use typeof first to print the parameters you want to compare, and judge first. Type

    2. Judge their values

      If all are equal, true will be returned. Generally, no one compares arrays, which is more troublesome

    3. ==, it is a simple comparison of values. As for the type, it does not matter, that is, 1 of the number type and 1 of the string type, the values ​​​​are equal

    reply
    0
  • 张

    2017-10-28 08:56:13

    It is recommended that you take a good look at the usage of ""====""

    reply
    0
  • 帅帅的阿猪

    帅帅的阿猪2017-10-26 09:39:23

    === It means that all are equal, and the values ​​and types are equal, it is called congruent.

    reply
    0
  • Cancelreply