Find out the difference between the
var functionOne = function() {} AND function functionTwo() { }
The difference is that functionOne
is a function expression and so only defined when that line is reached, whereas functionTwo
is a function declaration and is defined as soon as its surrounding function or script is executed
For example, a function expression
functionOne();
// TypeError: functionOne is not a function
var functionOne = function() {
console.log("Hello seoinfotech!");
};
And, a function declaration
functionTwo();
//Hello seoinfotech
function functionTwo() {
console.log("Hello seoinfotech");
}