Can someone explain why in javascript,
alert({} == true) shows false
if ({}) alert(\'true\') shows true ?
What\’s different in the if condition that changes the result?
I wanted to write some shorthand argument validator obj || (obj = {}); and I was baffled by this discovery.





Rating:
The post Is {} == true or not in javascript? appeared first on Javascript ASK.
via Javascript ASK http://javascriptask.phpfogapp.com/is-true-or-not-in-javascript.html
No comments:
Post a Comment