A script is usually executed in a top-down approach. Instead of letting the browser proceed as you wish, you can set a condition that would control the sequence of processing. If the condition you set if true, then you can perform a desired operation. This processing is performed using the if condition.