JavaScript中的基础测试题

                                                                                                JavaScript中的基础测试题

1.我们可以在下列哪个 HTML 元素中放置 Javascript 代码?()

 A.<script>

 B.<javascript>

 C.<js>

 D.<scripting>

2.写 "Hello World" 的正确 Javascript 语法是?()

 A.("Hello World")

 B."Hello World"

 C.response.write("Hello World")

 D.document.write("Hello World")

 

3.插入 Javacript 的正确位置是?()

 A.<body>部分

 B.<head>部分

 C.<body>部分和<head>部分均可

4.引用名为 "xxx.js" 的外部脚本的正确语法是?()

 A.<script src="xxx.js">

 B.<script href="xxx.js">

 C.<script name="xxx.js">

 

5.如何在警告框中写入 "Hello World"?()

 A.alertBox="Hello World"

 B.msgBox("Hello World")

 C.alert("Hello World")

 D.alertBox("Hello World")

6.如何创建函数?()

 A.function:myFunction()

 B.function myFunction()

 C.function=myFunction()

 

7.如何调用名为 "myFunction" 的函数?()

 A.call function myFunction

 B.call myFunction()

 C.myFunction()

8.如何编写当 i 等于 5 时执行一些语句的条件语句?()

 A.if (i==5)

 B.if i=5 then

 C.if i=5

 D.if i==5 then

9.如何编写当 i 不等于 5 时执行一些语句的条件语句?()

 A.if =! 5 then

 B.if >< 5

 C.if (i >< 5)

 D.if (i != 5)



10.在 JavaScript 中,有多少种不同类型的循环?()

 A.两种。for 循环和 while 循环。

 B.四种。for 循环、while 循环、do...while 循环以及 loop...until 循环。

 C.一种。for 循环。

 

11.for 循环如何开始?()

 A.for (i <= 5; i++)

 B.for (i = 0; i <= 5; i++)

 C.for (i = 0; i <= 5)

 D.for i = 1 to 5

 

12.如何在 JavaScript 中添加注释?()

 A.' This is a comment

 B.<!--This is a comment-->

 C.//This is a comment

 

13.可插入多行注释的 JavaScript 语法是?()

 A./*This comment has more than one line*/

 B.//This comment has more than one line//

 C.<!--This comment has more than one line-->

14.定义 JavaScript 数组的正确方法是?()

 A.var txt = new Array="George","John","Thomas"

 B.var txt = new Array(1:"George",2:"John",3:"Thomas")

 C.var txt = new Array("George","John","Thomas")

 D.var txt = new Array:1=("George")2=("John")3=("Thomas")

15.如何把 7.25 四舍五入为最接近的整数?()

 A.round(7.25)

 B.rnd(7.25)

 C.Math.rnd(7.25)

 D.Math.round(7.25)

16.如何求得 2 和 4 中最大的数?()

 A.Math.ceil(2,4)

 B.Math.max(2,4)

 C.ceil(2,4)

 D.top(2,4)

17.打开名为 "window2" 的新窗口的 JavaScript 语法是?()

 A.open.new("http://www.w3cschool.cn","window2")

 B.new.window("http://www.w3cschool.cn","window2")

 C.new("http://www.w3cschool.cn","window2")

 D.window.open("http://www.w3cschool.cn","window2")

18.如何在浏览器的状态栏放入一条消息?()

 A.statusbar = "put your message here"

 B.window.status = "put your message here"

 C.window.status("put your message here")

 D.status("put your message here")

19.如何获得客户端浏览器的名称?()

 A.client.navName

 B.navigator.appName

 C.browser.name

20.外部脚本必须包含 <script> 标签。()

答案:

1-5:       ADCAC

6-10:     BCADA

11-15:   BCACD

16-20:   BDBBB

猜你喜欢

转载自www.cnblogs.com/mahmud/p/10124877.html