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

CodePudding user response:

reference 1st floor winzond 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 dead cycle

Write no possible code indentation is a bit messy expression is unclear function is a function in the body of the function I want after the return from the call tostring function

CodePudding user response:

reference 1st floor winzond 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 dead cycle

Since the call should be expressed as at a particular moment

CodePudding user response:

refer to the second floor qq_44896278 response:
Quote: refer to 1st floor winzond 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 dead cycle

Writes not possible code indentation is a bit messy expression is unclear function is a function in the body of the function I want after the return from the call tostring function

When returned by the function in mathematical expression is automatically calls toString,
Var num2=0 + add (1, 2)



CodePudding user response:

  • Related