Home >Web Front-end >JS Tutorial >How to define two functions in javascript
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)//可以调用
The second way: the function can only be called after the
function is defined.
(1) Definition of function
##var add2=function (ax,ay) {
alert(ax+ay) ;
}
(2) Function call
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!