There are three printing methods in JavaScript, namely window.alert(), document.write() and console.log().
#The operating environment of this article: windows10 system, javascript 1.8.5, thinkpad t480 computer.
In JavaScript, we usually use the following three ways to print data:
Use window.alert() to write the warning box
Use document.write() to write HTML output
Use console.log() to write to browser console
Let’s take a look at how they are used.
Using window.alert()
You can use an alert box to display data:
Example
我的第一张网页
我的第一个段落
Use document.write()
For testing purposes, it is more convenient to use document.write():
Example
我的第一张网页
我的第一个段落
Use console.log()
In the browser, you can Use the console.log() method to display data.
Please activate the browser console via F12 and select "Console" in the menu.
Example
我的第一张网页
我的第一个段落
Related video tutorial sharing:javascript video tutorial
The above is the detailed content of There are several printing methods in javascript. For more information, please follow other related articles on the PHP Chinese website!