The preventDefault() method is used for canceling an event if it is cancelable. It means that the default action that belongs to the event will not occur. However, all events are not cancelable and to find out those events use the cancelable property. It also does not prevent further propagation, therefore, use stopPropagation() for this purpose.
Its syntax is:- event.preventDefault()