Warning (alert)
Did you ever get into a situation like this when you visit a website? "Boom", a small window appears in front of you, with a piece of warning text written, or other information. If you don't click OK, you won't be able to do anything with the page. Yes, this little "boom" window is alert.
The following code is an instance of using alert.
My personal view is to use alert as little as possible and it is unfriendly. It may even make some parties think your site is dangerous.
Look at an instance confirmation using Alert (confirm)
A confirmation box is used to let the user choose whether a problem is realistic.
Said Yes or No. Quick answer. ”
If you want to express such meaning, then confirm is more suitable. Look at the following code: we use confirm ("Are you a rookie?"). To ask the visitor, variable R saves the visitor's response, and it can only have two values: TRUE or FALSE. Yes, it's a Boolean value. The statement behind confirm is a different response to our visitors ' answers.
Look at an instance of using Confirm (prompt)
Prompt is similar to confirm, but it allows visitors to enter the answer at random. Let's revise the example of the previous switch, and we'll make a different evaluation based on the score, but the procedure is not complete, it doesn't ask us for a score, it's supposed to be 65 points. It's not fair. Now I can use prompt to ask visitors questions, use score to store user input answers, and the rest is done by the switch behind.