Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (13.1k points)

Can anyone help me with this types of code for declaring functions and what is the difference between them?

var functionOne = function() {

    // Some code

};

Second way:

function functionTwo() {

    // Some code

}

Any help would be appreciated.

1 Answer

0 votes
by (26.7k points)

Basically, the fucntionOne is a function expression and can only be defined whenever it reaches that line of code, whereas, fucntionTwo is a function definition that will be defined as the script is executed.

I hope this will help.

Want to know more about Java? Prefer this tutorial on Java Tutorial.

Want to become a Java Expert? Join Java Training now!!

Browse Categories

...