JavaScript - Return from an anonymous function (varScope)

<script> var sample = function() { (function() { return "something" })(); // how can I return it here again? } </script> 

Is there a way to return the return value from an anonymous function to the parent function again, or do I need to use a specific function to get the return value? Thank you :)

+7
source share
1 answer

Just put the return statement where you call the function.

 <script> var sample = function() { return (function() { // The function returns when you call it return "something" })(); } </script> 
+6
source

All Articles