JavaScript performance difference between double equals (==) and triple equals (===)

前端 未结 6 398
刺人心
刺人心 2020-11-29 06:06

In JavaScript, is there a performance difference between using a double equals (==) vs using a triple equals (===)?

Example: if (foo

6条回答
  •  爱一瞬间的悲伤
    2020-11-29 06:59

    It depends on the items being compared. Since "===" is more strict than "==", it should return false faster than "==". However, if the two items are strictly equal "===" should take more time than "==" because it has to check more properties for equality.

提交回复
热议问题