Link to home
Start Free TrialLog in
Avatar of MJ
MJFlag 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

Avatar of Duy Pham
Duy Pham
Flag of Viet Nam image

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.
Avatar of MJ

ASKER

Hi Duy,
So the return is not necessary then?
ASKER CERTIFIED SOLUTION
Avatar of Duy Pham
Duy Pham
Flag of Viet Nam image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial