Why is 'false' truthy in javascript?

前端 未结 5 1704
面向向阳花
面向向阳花 2021-01-19 10:46

I understand that an empty string is falsy in javascript and a not-empty string is truthy in javascript.

However, why is \'false\' truthy in javascript,

5条回答
  •  心在旅途
    2021-01-19 11:07

    is there anything explicit in the specification?

    Yes:

    The result is false if the argument is the empty String (its length is zero); otherwise the result is true.

提交回复
热议问题