What is the difference in writing var funcName = function () {}; and function funcName(){};?


The question is why write

var funcName = function (){};

when you can write function funcName() {}; which is 1)shorter 2) more like Java (the biggest OOP language)?


var funcName = function(){}; means that the result of the function is stored in the variable funcName

function myFunction(a, b) {
return a * b;

var x = myFunction(4, 3); -> this means that x is will store the result (12)


Ok in the var funcName = function () {}; the name of the function is omitted and hence the function becomes anonymous and unrecyclable. Thank you!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.