As the window object has global scope, its methods can be called without reference to the window object.
The confirm() method takes a single optional argument which is the text that would be displayed on the dialog box. As stated above the confirm() method also returns a true or false value.
Using the confirm() method
You can simply call the confirm() method with an optional string to prompt the user for a Yes or No answer:
You should store the value returned by the confirm() method inside a variable so it can be used later