Snippets tagged “functions”
11 snippets use this tag.
- Changing a global variable from inside a function PHPPHP
In PHP, global variables can be accessed and modified from within functions using the global keyword.
- How do I detect whether a variable is a function?Python
In Python, you can use the built-in callable() function to check if a variable is a function.
- How JavaScript Closures WorkJavaScript
In the following snippet, we are going to represent how JavaScript closures work. The easiest way of learning how to use them is investigating examples.
- How to Capitalize the First Letter in a String in JavaScriptJavaScript
Read this JavaScript tutorial and learn the methods and undertake some steps which will help you make the first letter in the string uppercase easily.
- How to Check if Function Exists in JavaScriptJavaScript
In this tutorial, you will read and learn information about the two methods of checking whether a function exists in JavaScript or it has not been defined.
- How to Get the First Element of an Array in PHPPHP
This snippet gives you an opportunity to learn how to get the first element of an array using PHP. You can choose among the provided functions.
- How to list all functions in a module?Python
To list all functions in a module, you can use the dir() function to get a list of all the names defined in the module, and then use the inspect module to check if each name is a function.
- How to Use the func_get_arg() Function in PHPPHP
In this snippet, we will demonstrate to you how to use one of the common PHP functions: func_get_arg().
- How to Write a Function that Accepts Any Number of Arguments in JavaScriptJavaScript
Read this JavaScript tutorial and find two easy methods of writing a function that will accept an indefinite number of arguments. See and try examples.
- Using global variables in a functionPython
In Python, you can use global variables in a function by declaring the variable as global within the function.
- Why does Python code run faster in a function?Python
Python code can run faster in a function because of something called "Just-In-Time" (JIT) compilation.