JavaScript Tutorial #03 Outputs

Posted at: May 6, 2019 12:04 PM

In this lesson we will learn outputs in JavaScript.

Data display in JavaScript with different ways like as javascript alert, console.log(), document.write, innerhtml, innertext.

innerHTML

document.getElementById('result').innerHTML

Using this method data will be show in html format. result is id attribute of html element.

innerText

document.getElementById('result').innerText

Using this method data will be show in text format. Output like this <h2>JavaScript Output with innerText</h2>.

document.write('Content here')

document.write('Content here')

Using this method data will be show where is script is written.

console.log('Content here')

console.log('Content here')

Using this method data will be show in browser console.

alert('Content here') or window.alert()

alert('JavaScript output') or window.alert('JavaScript output')

You can use alert() or window.alert() both method for alert data.

Conclusion

In this lesson we have learnt how to get output data in JavaScript.

This lesson also available on YouTube
outputs in javascript javascript alert console.log() in javascript variable innerhtml javascript innertext javascript innerhtml vs innertext

Please leave comments

0 Comments