var functionName = function() {} vs function functionName() {}

I’ve recently started maintaining someone else’s JavaScript code. I’m fixing bugs, adding features and also trying to tidy up the code and make it more consistent. The previous developer used two ways of declaring functions and I can’t work out if there is a reason behind it or not. The two ways are: var functionOne … Read more

What does if __name__ == “__main__”: do?

What does this do? [python]if __name__ == "__main__": print("Hello world!") [/python]   40   Short It’s boilerplate code that protects users from accidentally invoking the script when they didn’t intend to. Here are some common problems when the guard is omitted from a script: If you import the guardless script in another script (e.g. import … Read more