return false the same as return?

前端 未结 8 1658
走了就别回头了
走了就别回头了 2020-12-01 03:33

Is

return false 

the same as:

return
8条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-01 03:57

    No.

    var i = (function() { return; })();

    i === undefined which means that i == false && i == '' && i == null && i == 0 && !i

    var j = (function() { return false; })();

    j === false which means that j == false && j == '' && j == null && j == 0 && !j

    Weak operators in JS make it seem like the might return the same thing, but they return objects of different types.

提交回复
热议问题