Home > front end >  Rookie help solve
Rookie help solve

Time:05-20


Why a var, less operation result are different

CodePudding user response:

Variable application range is not the same as

{
 function q (b) 
If (b.l ength<=1) {
return b;
} else {
R=b.s plice (parseInt (b.l ength/2), 1);
Var w=r [0];
Left=[];
Var right=[];
for(i=0; IIf (b [I] & gt; W) {
Left. Push (b [I])
} else {
Right. Push (b [I])
}
}
Document. Write (' w
')
Document. Write (w + '& lt; br/> ')
Var result=q (left). The concat (w, q (right))
Document. Write (' w callback
')
Document. Write (w + '& lt; br/> ')
return result;
}
}
Document. The write (q (a). The join (', '))

Var, variable in the current process effect, is not used with the caller
W
2
W
11.
W callback
11.
W callback
2
13,11,3,2,1

 var a=,3,2,11,13 [1] 
The function q (b) {
If (b.l ength<=1) {
return b;
} else {
R=b.s plice (parseInt (b.l ength/2), 1);
W=r [0];
Left=[];
Var right=[];
for(i=0; IIf (b [I] & gt; W) {
Left. Push (b [I])
} else {
Right. Push (b [I])
}
}
Document. Write (' w
')
Document. Write (w + '& lt; br/> ')
Var result=q (left). The concat (w, q (right))
Document. Write (' w callback
')
Document. Write (w + '& lt; br/> ')
return result;
}
}
Document. The write (q (a). The join (', '))

No var, detect the caller whether there is a variable with the same, if you have, the reference variables with the same
W
2
W
11.
W callback
11.
W callback
11.
13,11,3,11,1

CodePudding user response:

The first picture is don't know why the last w from 11 to 2, for big solutions
  • Related