We do JS debugging When using alert can display information, debugging programs, alert pop-up window will interrupt the program, if you want to display information in the loop, hand click Close Window is exhausted. And the alert display object is always displayed as [object]. I write the log although you can display some object information, but a lot of feature support is not console good
[1]alert ()
[1.1] Blocking action, no click OK, subsequent code can not continue to execute
[1.2]alert () can only output a string if the alert output is an object that automatically calls the ToString () method
e.g. alert ([+/-]);
[1.3]alert does not support the notation of multiple parameters, only the first value can be output
e.g. alert (//1);
[2]console.log ()
[2.1] output in Print station
[2.2] can print any type of data
e.g. Console.log ([+ +]);//[1,2,3]
[2.3] Support for the formulation of multiple parameters
e.g. Console.log (1 2 3)//
are alert and console.log different results?
Score = [1,2,3];sortedscore = [];console.log (score); Sortedscore = Score.sort (sortnumber) Console.log (Sortedscore); function Sortnumber (A, b) { return b-a;}
Above output:
[3, 2, 1]
[3, 2, 1]
But change to alert:
Web Design
Score = [1,2,3];sortedscore = [];alert (score); Sortedscore = Score.sort (sortnumber) alert (sortedscore); function Sortnumber (A, b) { return b-a;}
Above output:
1, 2, 3
3, 2, 1
Why is that? It should not all be:
1, 2, 3
3, 2, 1
It?
After some research found that chrome implementation of the problem, the output is not properly optimized, the actual execution of the Console.log deferred, equivalent to "lazy" evaluation, encountered in the array, object, such as the reference type of the above problem.
The difference between alert () and Console.log () in JavaScript