Home > front end > Want to ask how the body of the function since the call your function
Want to ask how the body of the function since the call your function
Time:01-22
The subject may not be able to describe the correct code below The function to the add (arr) { Var num=0 for(i=0; INum +=the arguments [I] } Var TMP=function (x) { Num +=x Return TMP } TMP. ToString=function () { Return num } Return TMP
} Var num1=add (1, 2) (3) Var num2=add (1, 2). The toString () The console. The log (num1, typeof (num1), num2, typeof (num2)) //==& gt; ? 6 "function", "3" number " The post said is if there is a default function body function will automatically perform But not only in the outside call is executed only when Want to ask whether can get 'number' type data directly
CodePudding user response:
(function () { Var x="Hello!!!!! ";//I will call the }) ();
so write would call itself, inside the body of the function call with external call no difference, but attention should be paid to set conditions, otherwise it is infinite loop