Your function stored in anonFunction is NOT anonymous. The act of assigning an anonymous function to a variable makes it acquire the name of that variable. This can be verified by checking the name property of the function:
// normal functionfunctiontest1(){return0}console.log(test1.name)// 'test1'// anonymous functionconsole.log((function (){return0}).name)// <empty string>// initially anonymous function stored in a variableconsttest2=function(){return0}console.log(test2.name)// 'test2' - no longer anonymous
Your function stored in
anonFunctionis NOT anonymous. The act of assigning an anonymous function to a variable makes it acquire the name of that variable. This can be verified by checking thenameproperty of the function:Most Developers Can't Answer This Question About Anonymous Functions 🤯
Jon Randy 🎖️ ・ Mar 27 '23