The first way: It can be called before the definition of function or it can be called after functionAfter definitionCall:
(0) Function call
##
add(1,2) //可以调用
(1) Function definition:
##function add(x,y) {
console.log(x+y) ;
}
add(1,2)//可以调用
function is defined.
(1) Definition of function
##var add2=function (ax,ay) {
alert(ax+ay) ;
}
add2(1,2)
The above is the detailed content of How to define two functions in javascript. For more information, please follow other related articles on the PHP Chinese website!