Note because it will be a mess ✍
Python | JavaScript | |
---|---|---|
"" | False | false |
[] | False | true |
{} | False | true |
Python
In [1]: True if "" else False
Out[1]: False
In [2]: True if [] else False
Out[2]: False
In [3]: True if {} else False
Out[3]: False
JavaScript
"" ? true : false;
false
[] ? true : false;
true
{} ? true : false;
VM1052:1 Uncaught SyntaxError: Unexpected token '?'
//What!?
//If so ↓
obj = {};
{}
obj ? true : false;
true
I don't know why the JS object got a Syntax error !! Since it is a memo article, I will check it separately at a later date.
Recommended Posts