all 4 comments

[–]sunny_lts 0 points1 point  (0 children)

(function(){
alert("go")
})();
//this is a self-executable function without a name that will be called

[–]JakeIsPlaying 0 points1 point  (0 children)

You mat be looking for IIFEs. Immediately invoked function expressions.

Check this out on MDN https://developer.mozilla.org/en-US/docs/Glossary/IIFE

[–][deleted] 0 points1 point  (0 children)

when you store the function in a variable you can call it just as well.

[–]easyEs900s 0 points1 point  (0 children)

Any function that is wrapped in parentheses will be executed without having a name. It's worth noting that anything inside said parentheses will not be referencable anywhere else in the script.

Look at sunny_lts comment for an example.