温馨提示×

javascript输出语句有哪些

养鱼的猫咪
393
2021-04-12 11:52:47
栏目: 编程语言

javascript中的输出语句有:1.alert语句,显示消息给用户;2.console.log语句,在浏览器控制台中打印输出信息;3.document.write语句,在网页中输出内容;


javascript输出语句有哪些


javascript中的输出语句有以下几种

1.alert语句

javascript中alert语句的作用是用于显示消息给用户,常用于创建一个消息警告框。

alert语句使用方法:

<script type="text/javascript">
   alert("hello world!");
</script>

2.console.log语句

javascript中console.log语句的作用是在浏览器控制台中打印输出信息。

console.log语句使用方法:

<script type="text/javascript">
   console.log("hello world!");
</script>

3.document.write语句

javascript中document.write语句的作用是在网页中输出内容,常用于向网页输出一段文字。

document.write语句使用方法:

<script type="text/javascript">
   document.write("hello world!");
</script>


0