Home > front end >  The console. The log output array do not agree with the real
The console. The log output array do not agree with the real

Time:10-09

/n * n yuan to buy the rabbit problem */
The function exhaustiveSearch (n) {
Cases in=new Array ();
Rabbit=new Array ();
Rabbit [" male "]=0;//number of male rabbit
Rabbit [" female "]=0;//mother rabbit quantity
Rabbit (" child ")=0;//number of the young rabbit
5 yuan//and a rabbit, it must be less than n/5 only
For (rabbit [" male "]=0; Rabbit [" male "] //mother rabbit a 3 yuan, it must be less than n/3 only
For (rabbit [" female "]=0; Rabbit [" female "] //the young rabbit quantity must be n - mother - male rabbit rabbit
For (rabbit (" child ")=(n - rabbit [] "male" - rabbit [" female "]); Rabbit [" child "] //the console. The log (" equal to the total ");
If (rabbit (" child ") % 3==0) {
//the console. The log (" the rabbit one yuan three ");
If (rabbit [" male "] * 5 + rabbit [" female "] * 3 + rabbit [" child "]/3==n) {
The console. The log (rabbit); Output//* * * *
Cases. Push (rabbit);
}
}
}
}
}
//the console log (cases);
The return cases;
}


So, why do not match the output fluctuation

CodePudding user response:

One is the output value, is the value of the end of the cycle

CodePudding user response:

The console. The log output shows that the properties of the object, is when the mouse to click the triangle on the properties of the value, not the console. The value of the log output

CodePudding user response:

Chrome console print object is referenced, the default no, unfolds is, the value of the last modification, so a [...]. Value is different, the same problem, you see the last have an exclamation mark, is to prompt the use of

Direct print string

 
The console. The log (JSON. Stringify (rabbit));




Web development learning materials recommended
Javascript running mechanism analyses
XDomainRequest, IE8 + cross-domain request object

CodePudding user response:

refer to the second floor sky waves reply:
console. The log output shows that the properties of the object, is the mouse to click the triangle on the attribute value, not the console. At the time of the log output value


Climb up and logged on to give you some praise, waste for three hours on this matter, I say how to print the value of the wrong
  • Related