[1]alert ()
[1.1] Blocking action, no click OK, subsequent code cannot continue execution
[1.2]alert () can output only string if alert outputs an object that automatically calls the ToString () method
e.g. alert ([1,2,3]);//' 1,2,3 '
[1.3]alert does not support the writing of multiple parameters, only the first value can be output
e.g. alert (1,2,3);//1
[2]console.log ()
[2.1] On the print table output
[2.2] can print any type of data
e.g. console.log ([1,2,3]);//[1,2,3]
[2.3] To support multiple parameters of the wording
e.g Console.log (1,2,3)//1 2 3
Are the results of alert and console.log different?
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:
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? Should not all be:
1, 2, 3
3, 2, 1
Do you?
After a study found that the problem is the implementation of chrome, the output did not fit the optimization, the actual execution of the Console.log deferred, the equivalent of "lazy" evaluation, the array, objects such as the reference type on the above problem.
https://bugs.webkit.org/show_bug.cgi?id=35801
This is a very historical BUG that has been fixed in the development version last month.