# same:
not not "" # False
not not 0 # False
not not 1 # True
not not None # False
# different:
not not {} # False
not not [] # False
not not tuple() # False
for...of is easier to read and recognize as a loop construct at first glance, and as far as I recall it's also faster nowadays since the body of the loop is inline, whereas forEach requires the runtime to deal with a function object.
Makes me wonder if maybe the syntax for mapping, folding and other collection operations should have a similar syntax to for instead of the current method-style syntax popular in most modern languages.
for each(str from [list: "Ahoy", "world!"]):
print(str)
end
for map(n from [list: 1,2,3]): n * n end
# ==> [list: 1, 4, 9]
for filter(n from [list: 1, 2, 3]):
n >= 2
end
# ==> [list: 2, 3]
for fold(sum from 0, n from [list: 4, 5, 6]):
sum + n
end
# ==> 15
It would be nice to have a sectioin with things that work differently in both languages. For example in python `if []:` evaluates to False while in javascript `if ([]) {` evaluates to True.
Thanks for the site! Do you have thoughts on removing all the print/console.logs calls on every line? It feels like there's a lot of visual noise there, that can still be met with the comments showing state/output.
I think anyone who hasn't learned to do X in Python already really should be better off learning it in Python 3 rather than a version of the language which is in the process of deprecation.
Although this is a case where idiomatic python is different from idiomatic js.
In js:
while in python: