Home > Web Front-end > JS Tutorial > How to define two functions in javascript

How to define two functions in javascript

一个新手
Release: 2017-10-14 09:45:28
Original
1353 people have browsed it

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) //可以调用
Copy after login

(1) Function definition:

##

function add(x,y) {
       console.log(x+y) ;
    }
Copy after login

(2) Function call

add(1,2)//可以调用
Copy after login
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) ;
    }
Copy after login
(2) Function call

 add2(1,2)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template