Avatar of MJ
MJ
Flag for United States of America asked on

Purpose of returning an anonymous function?

What is the purpose of using the return leading the function? Does it matter as long as you are returning within the function?
return (function() { 
  "use strict";
  var u12Value ;
  try {
    if(!!document.cookie && document.cookie.indexOf("CUSTOMER")!==-1) {
      u12Value = 1;
  } 
    else
    {
       u12Value = 0;
    }
  }catch(e) {}
	return u12Value;
})();

Open in new window

JavaScript

Avatar of undefined
Last Comment
Duy Pham

8/22/2022 - Mon
Duy Pham

It's just an inline function declared right when returning value. As long as that return statement is inside a function, it should be just fine.
MJ

ASKER
Hi Duy,
So the return is not necessary then?
ASKER CERTIFIED SOLUTION
Duy Pham

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck