I’ve just started working with javascript and I saw something which I can’t explain.
I have js file named TestClass.js and its the following:
TestClass.SetError = function (errorDescription, errorCode, typedErrorCode)
{
alert("SetError ");
}
function SetError2(errorCode)
{
alert("SetError2 ");
}
Can someone please explain me the difference between the SetError and SetError2?
The first piece of code (SetError) contains
Anonymous Function Expression, where the second piece of code (SetError2) cotains aFunction Declaration. See Function Declarations vs. Function ExpressionsAnother good article: Named function expressions demystified
Excerpt:
That’s basically the main difference. It’s not huge but worth being aware of.