June
26th,
2017
JavaScript can “display” data in different ways:
- Writing into an HTML element, using
innerHTML
.Changing the innerHTML property of an HTML element is a common way to display data in HTML.
- Writing into the HTML output using
document.write()
.- Using document.write() after an HTML document is fully loaded, will delete all existing HTML.
The document.write() method should only be used for testing.
- Using document.write() after an HTML document is fully loaded, will delete all existing HTML.
- Writing into an alert box, using
window.alert()
. - Writing into the browser console, using
console.log()
.- For debugging purposes, you can use the console.log() method to display data.