Differences in authenticity between Python and JavaScript

Note because it will be a mess ✍

Summary

Python JavaScript
"" False false
[] False true
{} False true

Operation verification

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

Differences in authenticity between Python and JavaScript
Differences between Ruby and Python in scope
Differences in syntax between Python and Java
Differences in multithreading between Python and Jython
Difference between list () and [] in Python
Difference between == and is in python
Differences between Python, stftime and strptime
difference between statements (statements) and expressions (expressions) in Python
Difference between @classmethod and @staticmethod in Python
Difference between append and + = in Python list
Difference between nonlocal and global in Python
Differences between Ruby and Python (basic syntax)
Differences between queryStringParameters and multiValueQueryStringParameters in AWS Lambda
Summary of the differences between PHP and Python
[python] Difference between variables and self. Variables in class
About the difference between "==" and "is" in python
Differences in string processing between Python, Ruby, JS, PHP (combination and variable expansion)
Difference between Ruby and Python in terms of variables
Calculate Pose and Transform differences in Python with ROS
Stack and Queue in Python
Mutual conversion between JSON and YAML / TOML in Python
Difference between return, return None, and no return description in Python
Unittest and CI in Python
Compare "relationship between log and infinity" in Gauche (0.9.4) and Python (3.5.1)
Differences in behavior between append () and "+ =" operators when adding data to a list in Python
Python module num2words Difference in behavior between English and Russian
List concatenation method in python, difference between list.extend () and “+” operator
I tried to enumerate the differences between java and python
Remove leading and trailing whitespace in Python, JavaScript, or Java
Differences between Windows and Linux directories
Difference between java and python (memo)
MIDI packages in Python midi and pretty_midi
Differences between yum commands and APT commands
View photos in Python and html
Sorting algorithm and implementation in Python
Differences between symbolic links and hard links
Manipulate files and folders in Python
About dtypes in Python and Cython
Assignments and changes in Python objects
Cooperation between python module and API
Check and move directories in Python
Difference between python2 series and python3 series dict.keys ()
Ciphertext in Python: IND-CCA2 and RSA-OAEP
Hashing data in R and Python
Function synthesis and application in Python
Export and output files in Python
Compare Python and JavaScript array loops
[Python] Difference between function and method
Reverse Hiragana and Katakana in Python2.7
Reading and writing text in Python
[GUI in Python] PyQt5-Menu and Toolbar-
Python --Difference between exec and eval
[Python] Difference between randrange () and randint ()
Differences in identity, equivalence, and aliases
Differences between Python, read (), readline (), readlines ()
[Python] Difference between sorted and sorted (Colaboratory)
Create and read messagepacks in Python
Difference in how to write if statement between ruby ​​and python
Transcendental simple and clear! !! Difference between single quotes and double quotes in Python
Summary of differences between Python and PHP (comparison table of main items)
File open function in Python3 (difference between open and codecs.open and speed comparison)