console.log(); vs window.alert();
console.log()
All modern web browsers, Node.js, as well as almost every other JavaScript environment, support writing messages to a console using a suite of logging methods. The most common of these methods is console.log().
In a browser environment, the console.log() function is predominantly used for debugging purposes. To get started open up the JavaScript Console in your browser, type the following, and press enter.
console.log("Hello, World!");
In the example above, the console.log() function prints Hello, World! to the console and returns undefined (shown above in the console output window). This is because console.log() has no explicit return value.
window.alert()
The alert method displays a visual alert box on screen. The alert method parameter is displayed to the user in plain text:
window.alert(message);
Because window is the global object, you can call also use the following shorthand:
alert(message);
So what does window.alert() do? Well, let's take the following example:
alert('hello, world');
However, the specification actually allows other event-triggered code to continue to execute even though a modal dialog is still being shown. In such implementations, it is possible for other code to run while the modal dialog is being shown.
The use of alerts is usually discouraged in favor of other methods that do not block users from interacting with the page - in order to create a better user experience. Nevertheless, it can be useful for debugging.
In Chrome 46.0, window.alert() is blocked inside an <iframe> unless its sandbox attribute has the value allow-modal.
Unlike using console.log , alert acts as a modal prompt meaning that the code calling alert will pause until the prompt is answered. Traditionally this means that no other JavaScript code will execute until the alert is dismissed
And its DRAW all win because console.log and window.alert are used in their respective or purpose.
Enjoy code, Enjoy Life </>