DEV Community

Discussion on: JavaScript is almost pythonic

Collapse
 
jbendelbrot profile image
Joshua Bendelbrot

I'd better keep apart semantics and tinkering with lang:

JS:

0 in [1,2,3] === true
1 in [1,2,3] === true
// Wrong usage because JS expects Object

Python:

(0 in [1,2,3]) == False
(1 in [1,2,3]) == True

But, JS:

'1' in {'1': null} === true // correct

and Python:

(1 in {1: None}) == True

Thus historically JS is much more ad-hoc with all the consequences.