练习02 JS小测验
对于下面每个问题,请写下你认为正确的回答。
请将正确的答案的文字描述写在“答:”之后,不能用A、B、C、D代替。
1 . 我们可以在下列哪个 HTML 元素中放置 Javascript 代码?
. <script>
. <javascript>
. <js>
. <scripting>
答:<script>
2 . 写 "Hello World" 的正确 Javascript 语法是?
. ("Hello World")
. "Hello World"
. response.write("Hello World")
. document.write("Hello World")
答:document.write("Hello World")
3 . 插入 Javacript 的正确位置是?
. <body> 部分
. <head> 部分
. <body> 部分和 <head> 部分均可
答:<body> 部分和 <head> 部分均可
4 . 引用名为 "xxx.js" 的外部脚本的正确语法是?
. <script src="xxx.js">
. <script href="xxx.js">
. <script name="xxx.js">
答:<script src="xxx.js">
5 . 外部脚本必须包含 <script> 标签吗?
. 是
. 否
答:否
6 . 如何在警告框中写入 "Hello World"?
. alertBox="Hello World"
. msgBox("Hello World")
. alert("Hello World")
. alertBox("Hello World")
答:alert("Hello World")
7 . 如何创建函数?
. function:myFunction()
. function myFunction()
. function=myFunction()
答:function myFunction()
8 . 如何调用名为 "myFunction" 的函数?
. call function myFunction
. call myFunction()
. myFunction()
答:myFunction()
9 . 如何编写当 i 等于 5 时执行一些语句的条件语句?
. if (i==5)
. if i=5 then
. if i=5
. if i==5 then
答:if (i==5)
10 . 如何编写当 i 不等于 5 时执行一些语句的条件语句?
. if =! 5 then
. if <>5
. if (i <> 5)
. if (i != 5)
答:if (i != 5)
11 . 在 JavaScript 中,有多少种不同类型的循环?
. 三种。for 和for…in以及 while 循环。
. 四种。for 循环、while 循环、do...while 循环以及 loop...until 循环。
. 一种。for 循环。
答:三种。for 和for…in以及 while 循环。
12 . for 循环如何开始?
. for (i <= 5; i++)
. for (i = 0; i <= 5; i++)
. for (i = 0; i <= 5)
. for i = 1 to 5
答:for (i = 0; i <= 5; i++)
13 . 如何在 JavaScript 中添加注释?
.'This is a comment
. <!--This is a comment-->
. //This is a comment
答://This is a comment
14 . 可插入多行注释的 JavaScript 语法是?
. /*This comment has more than one line*/
. //This comment has more than one line//
. <!--This comment has more than one line-->
答:/*This comment has more than one line*/
15 . 定义 JavaScript 数组的正确方法是?
. var txt = new Array="George","John","Thomas"
. var txt = new Array(1:"George",2:"John",3:"Thomas")
. var txt = new Array("George","John","Thomas")
. var txt = new Array:1=("George")2=("John")3=("Thomas")
答:var txt = new Array("George","John","Thomas")
16 . 如何把 7.25 四舍五入为最接近的整数?
. round(7.25)
. rnd(7.25)
. Math.rnd(7.25)
. Math.round(7.25)
答:Math.round(7.25)
17 . 如何求得 2 和 4 中最大的数?
. Math.ceil(2,4)
. Math.max(2,4)
. ceil(2,4)
. top(2,4)
答:Math.max(2,4)
18 . 打开名为 "window2" 的新窗口的 JavaScript 语法是?
. open.new("http://www.w3school.com.cn","window2")
. new.window("http://www.w3school.com.cn","window2")
. new("http://www.w3school.com.cn","window2")
. window.open("http://www.w3school.com.cn","window2")
答:window.open("http://www.w3school.com.cn","window2")
19 . 如何在浏览器的状态栏放入一条消息?
. statusbar = "put your message here"
. window.status = "put your message here"
. window.status("put your message here")
. status("put your message here")
答:window.status = "put your message here"
20 . 如何获得客户端浏览器的名称?
. client.navName
. navigator.appName
. browser.name
答:navigator.appName