I recently began maintaining the JavaScript code of another person. I am fixing bugs, adding features, and trying to make the code cleaner and more consistent.
The previous developer used two different ways to declare functions. I’m not sure if it was intentional.
The two ways are:
var functionOne = function() {
// Some code
};
function functionTwo() {
// Some code
}
Which method is best for you? What are your reasons for choosing these methods and which are your pros and cons? What can one method do that the other can’t?