Use Selenium WebDriver To Manage Javascript Popup

When we do manual test we always encounter javascript popup such as Alert, Prompt and Confirm in web pages. But how to handle those javascript popup automatically in selenium automation test? You can use Alerts API to process such javascript issues in Selenium WebDriver.