“Parameter” vs “Argument” [duplicate]

This question already has answers here: What’s the difference between an argument and a parameter? (36 answers) Arguments or parameters? [duplicate] (12 answers) Closed 2 years ago. I got parameter and argument kind of mixed up and did not really pay attention to when to use one and when to use the other. Can you … Read more

Which exception should I raise on bad/illegal argument combinations in Python?

I was wondering about the best practices for indicating invalid argument combinations in Python. I’ve come across a few situations where you have a function like so: def import_to_orm(name, save=False, recurse=False): “”” :param name: Name of some external entity to import. :param save: Save the ORM object before returning. :param recurse: Attempt to import associated … Read more

Is there a better way to do optional function parameters in JavaScript? [duplicate]

This question already has answers here: Set a default parameter value for a JavaScript function (29 answers) Closed 5 years ago. I’ve always handled optional parameters in JavaScript like this: function myFunc(requiredArg, optionalArg){ optionalArg = optionalArg || ‘defaultValue’; // Do stuff } Is there a better way to do it? Are there any cases where … Read more

What’s the difference between an argument and a parameter?

When verbally talking about methods, I’m never sure whether to use the word argument or parameter or something else. Either way the other people know what I mean, but what’s correct, and what’s the history of the terms? I’m a C# programmer, but I also wonder whether people use different terms in different languages. For … Read more

Passing parameters to a Bash function

I am trying to search how to pass parameters in a Bash function, but what comes up is always how to pass parameter from the command line. I would like to pass parameters within my script. I tried: myBackupFunction(“..”, “…”, “xx”) function myBackupFunction($directory, $options, $rootPassword) { … } But the syntax is not correct. How … Read more

How do I parse command line arguments in Bash?

Say, I have a script that gets called with this line: ./myscript -vfd ./foo/bar/someFile -o /fizz/someOtherFile or this one: ./myscript -v -f -d -o /fizz/someOtherFile ./foo/bar/someFile What’s the accepted way of parsing this such that in each case (or some combination of the two) $v, $f, and $d will all be set to true and … Read more

Set a default parameter value for a JavaScript function

I would like a JavaScript function to have optional arguments which I set a default on, which get used if the value isn’t defined (and ignored if the value is passed). In Ruby you can do it like this: def read_file(file, delete_after = false) # code end Does this work in JavaScript? function read_file(file, delete_after … Read more

How do I pass command line arguments to a Node.js program?

I have a web server written in Node.js and I would like to launch with a specific folder. I’m not sure how to access arguments in JavaScript. I’m running node like this: $ node server.js folder here server.js is my server code. Node.js help says this is possible: $ node -h Usage: node [options] script.js … Read more