Top "Function" questions

A function (also called a procedure, method, subroutine, or routine) is a portion of code intended to carry out a single, specific task.

Passing an array as a function parameter in JavaScript

I'd like to call a function using an array as parameters: const x = ['p0', 'p1', 'p2']; call_…

javascript arrays function call
How do I create a Python function with optional arguments?

I have a Python function which takes several arguments. Some of these arguments could be omitted in some scenarios. def …

python function arguments optional-arguments
How to return 2 values from a Java method?

I am trying to return 2 values from a Java method but I get these errors. Here is my code: // Method …

java function return-value
What is the scope of variables in JavaScript?

What is the scope of variables in javascript? Do they have the same scope inside as opposed to outside a …

javascript function variables scope var
What is the naming convention in Python for variable and function names?

Coming from a C# background the naming convention for variables and method names are usually either camelCase or PascalCase: // C# …

python variables function naming-conventions
PHP Fatal error: Using $this when not in object context

I've got a problem: I'm writing a new WebApp without a Framework. In my index.php I'm using: require_once(…

php function class object fatal-error
How do Python functions handle the types of the parameters that you pass in?

Unless I'm mistaken, creating a function in Python works like this: def my_func(param1, param2): # stuff However, you don't …

python function parameters
How to call a function within class?

I have this code which calculates the distance between two coordinates. The two functions are both within the same class. …

python class function call
jQuery's .click - pass parameters to user function

I am trying to call a function with parameters using jQuery's .click, but I can't get it to work. This …

jquery function parameter-passing
How to plot multiple functions on the same figure, in Matplotlib?

How can I plot the following 3 functions (i.e. sin, cos and the addition), on the domain t, in the …

python function matplotlib graph