Boolean vs Int in Javascript

后端 未结 4 2014
独厮守ぢ
独厮守ぢ 2020-12-31 03:05

I always assumed that booleans were more efficient than ints at storing an on/off value - considering that\'s their reason for existence. I recently decided to check if this

4条回答
  •  不知归路
    2020-12-31 03:35

    For me the choice would be based on API usage. Always return that which is most useful. If I use secondary code, I'd favor methods that return booleans. This probably makes the code ready to be chained. The alternative is to provide overloaded methods.

提交回复
热议问题