This article analyzes the difference between js function and php function. Share it for your reference. The specific analysis is as follows:
In PHP syntax, a function is a syntax structure, not a variable and cannot be assigned;
In JS, a function is also a variable, and the variable name is the function name.
Copy the code as follows: <html>
<head>
</head>
<body>
<script type="text/javascript">
function t(){
return 5;
}
var m = t;//The function name is the variable name. Note that it cannot be written as t(), and brackets are used to indicate that this function is called.
alert(m());
</script>
</body>
</html>
Therefore, declaring functions can be done like this:
Copy the code as follows: t = function(parameter){
Function body;
}
I hope this article will be helpful to everyone's JavaScript programming.