Cool post, neat to see Python concepts explained from a JavaScript perspective. I have a few notes / clarifications on some of your points.
Return vs print: the way it was phrased made it seem like the print statement was similar to the return statement. Itβs not, print is just a function basically equivalent to console.log.
Scopes: you actually can modify global variables from a local scope by using the global keyword, like this:
global_var=1defmy_func():globalglobal_varglobal_var=2local_var="a"definner_func():nonlocallocal_var# similar to global for inner functions
local_var="b"
Arguments: you can have any number of optional arguments (arguments with defaults) after required arguments. There are also a lot more things you can do with arguments (arbitrary args, keyword only, required keywords, positional only) that are useful. They usually involve asterisks and Iβm sure youβll come across them later.
Cool post, neat to see Python concepts explained from a JavaScript perspective. I have a few notes / clarifications on some of your points.
Return vs print: the way it was phrased made it seem like the print statement was similar to the return statement. Itβs not, print is just a function basically equivalent to console.log.
Scopes: you actually can modify global variables from a local scope by using the
global
keyword, like this:These are not meant to be comprehensive tutorials that teach everything about a topic, they're my personal notes that I made into posts. But thanks