Javascript equality triple equals but what about greater than and less than?

后端 未结 4 2021
轮回少年
轮回少年 2021-02-07 05:11

I was explaining to a colleague that you should use === and !== (and >== and <== of course) when comparing variables in

4条回答
  •  梦毁少年i
    2021-02-07 05:43

    Is there some sort of operator for > and < that do not coerce the type

    No.

    how can I change my test to perform the test safely

    You would have to explicitly test the types:

    typeof a === typeof b && a > b
    

提交回复
热议问题