hope someone can help me.
I have a function like
<script language="JavaScript" type="text/javascript">
function my_test()
{
... some code ...
}
</script>
Is it possoble to rename (or clone) this function to my_test_2()
?
Thanks in advance!
Peter
A lot of jQuery functions are implemented as name: function () {}. For example, the following is the definition of the jQuery function grep. function grep( elems, callback, inv ) { var retVal, ret = [], i = 0, length = elems. length; inv = !!
A JavaScript function is defined with the function keyword, followed by a name, followed by parentheses (). Function names can contain letters, digits, underscores, and dollar signs (same rules as variables).
Invoking a JavaScript FunctionThe code inside a function is executed when the function is invoked. It is common to use the term "call a function" instead of "invoke a function". It is also common to say "call upon a function", "start a function", or "execute a function".
A function in JavaScript is similar to a procedure—a set of statements that performs a task or calculates a value, but for a procedure to qualify as a function, it should take some input and return an output where there is some obvious relationship between the input and the output.
Functions are first-class objects in Javascript. You can do:
var my_test_2 = my_test;
my_test_2(); // Calls the same function as my_test() does.
my_test_2 = my_test;
Functions are like variables, so my_test_2 will be a reference to the original.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With