I wanted to check whether a variable has a value (in my case function). I started to playing around in node cli and I found weird results:
Cases:
(function(){} == true) // returns false(function(){} == false) // returns false(!function(){} == true) // returns false(!function(){} == false) // returns false((function(){}) == true) // returns false(!(function(){}) == true) // returns false(!!function(){} == true) // returns true(!!function(){} == false) // returns falseBoolean(function(){}) // returns true
Can somebody explain why something like this happens?
Looks like correct boolean value is true for function(){}, but it returns false.
PS. In case my nodejs version - v5.8.0
Aucun commentaire:
Enregistrer un commentaire