What is the difference | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

What is the difference

what is the difference between alert and console.log in JavaScript?

7th Feb 2017, 4:14 AM
Ermyas
Ermyas - avatar
4 Answers
+ 12
Alert triggers a (visible) pop-up box while console.log writes in the (secret) console. Go test them....
7th Feb 2017, 5:30 AM
Valen.H. ~
Valen.H. ~ - avatar
+ 6
The difference is where the text output occurs ^^
7th Feb 2017, 4:54 PM
visph
visph - avatar
+ 3
alert and console.log are built in javascript functions. alert puts a popup on the screen with a message or a question you ask your user; one can also in an obtrusive way use it for code control. console.log will log in the console(F12 on chrome) whatever you pass to it. use it to check for the return value of a function or to chexk that callbacks work. alert(something) puts something in a popup/ console.log(something) puts something as return value in the development tools browser console. In the console tab.
7th Feb 2017, 5:34 AM
florin holban
florin holban - avatar
+ 3
Alert should be shown to the users while consold.log for developers (mostly debugging)
7th Feb 2017, 7:47 PM
Hasan Al-Yazidi
Hasan Al-Yazidi - avatar