JavaScript basic questions, exercises, exam questions, interview questions (a)

1. The following code is executed, respectively, pop values are:
var num1=1; function testf1(){ num1=2; var num1; alert(num1); } function testf2(){ alert(num1); } testf1(); testf2();
A 2,1
B 2,2 &
C undefined, undefined
D 2, undefined
correct Answer: A
analytic:
testf1 function first executed to perform variable lift, and the inside num1 private variable will not change the global variables
testf2 inside global variable num1

2.For (var I = 0; I <10; I ++) {+ SUM = I;} the console.log (I)
A. 8
B. 9
C 10
D. 11
correct answer: C
Analysis:
Continue function when i = 9 is and add a, i = 9 + 1

3.console.log ((2 == true) +1 ) will pop
A to true
B to false
C. 1
D 2
correct answer: C
2 == false to true, then a value of 0

4. in JS, "1555" is operating results +3
A 1558
B 1552
C 15553
D 1553
correct answer: C
Analysis:
15553
string is actually a numeric string concatenation +

5. The following code pop operation result is A = 888 var; ++ a; Alert (A ++);
A 888
B 889
C 890
D 891
correct answer: B
Analytical:
889
++ a first implementation and then incremented
++ a the first increase in execution

6.var x = 1; function fn ( n) {n = n + 1;}; y = fn (x); y is a value of
A 2
B. 1
C. 3
D undefined
correct answer: D
Analytical:
undefined

Statement is correct use 7.while
A the while I = (. 1 <> 10)
B the while (I <= 10)
C the while (I <= 10; I ++;)
D = I. 1 to 10 the while
correct answer: B
Analysis:
while (i <= 10)

8. Keyword Use the following statement is not a branch
A Case
B IF
C the else
D for
the correct answer: D
parsing:
for

9. The analysis of the code results in the output section is T = 10 var; function Test (Test) = T + {T Test; T = var. 3; the console.log (T);} Test (T);
A. 6
B. 3
C 13 is
D NaN
correct answer: B
Analysis:
3

10.Number (true) returns a value of
A to true
B 1
C 0
D NaN3
correct answer: B
analysis:
1

11. The following legal variable name is
A 5show
B return
C $ the User
D var
correct answer: C
Analysis:
variable name can not start with a number, A wrong; BD is key, C correct

12. The need to refer to on the html page script file myJs.js, the following statement is correct
A <script href="myJs.js" type="text/javascript" />
B <script src="myJs.js" type="text/javascript" />
C <script href="myJs.js" type="text/javascript"></script>
D <script src="myJs.js" type="text/javascript"></script>
The correct answer: D
resolved:
Script is a dual-label, src introduced documents

13. The output code is the Add function () {var. 1 + SUM = 2; the console.log (SUM);} the console.log (SUM);
A two outputs. 3
B outputs a. 3
C being given program
D outputs an undefined
The correct answer: C
parsing:
SUM is a local variable, the global environment is not defined

14. The output code is var str = ""; var i = 1; while (i <= 10) {if (i% 2) {str + = i + '';} i ++;} document.write (STR + '
');
A 1,3,5,7,9
B. 3. 1. 5. 7. 9
C 2,4,6,8,10
D 2,4,6,8
correct answer: B
Analysis:
odd with spaces splicing, the final output

15. Which of the following ways is the output in the console
A console.log ()
B document.write ()
C Alert ()
D prompt ()
the correct answer: A
parsing:
Alert () is a pop-up boxes, document.write () on the page is output, prompt () is a pop-up input box, only console.log () is a printing output in the console, so choose A

16. The following result codes are running. 5 = num var; function Fn () {num =. 1; Fn} (); Alert (num);
A. 1
B undefined
C given
D 5
correct Answer: A
resolution:
in the function num is global; the function performed globally to a 1 num; 1 and the printed

17.JavaScript code must appear in the following tag inside which can be executed?
Body A
B head
C div
D Script
The correct answer: D
resolved:
Script tags can appear anywhere on the label of the page

18. Results The following code is run output A = B = 10 var; (function () {var = 20 is A = B}) (); the console.log (B);
A 10
B 20 is
C given
D undefined
correct answer: B
analysis:
function of b is global; b reassigned to a global 20, so the result is 20

19. Which of the following words does not belong javascript keyword
A BREAK
B float
C var
D return
the correct answer: B
parsing:
float is a reserved word in JavaScript, not keywords

20. There are the following code: var x = 10; function f1 (num) {++ num;} var y = f1 (x); console.log ( 'x =' + x + '; y =' + y); result of execution is
a X = 10; Y = undefined
B X = 10; Y =. 11
C X =. 11; Y =. 11
D X =. 11; Y = undefined
correct answer: a
parsing:
X = 10; Y = undefined

21. The following JS code: var i = 0; var sum = 0; do {i ++; if (i% 2 === 0) {continue;} if (i% 5 === 0) {break;} sum + = i;} while ( i <10); console.log ( 'sum =' + sum); results of its operation should be of the following
A SUM = 0
B = SUM. 4
C = Infinity SUM
D infinite loop
correct answer : B
analytical:
SUM =. 4

Score: 2 points
22. The following code, what will pop A var; Alert (A);
A given
B IS Not DEFINE A
C undefined
D 0
correct answer: C
Analysis:
variable lift

23. The following code, what will pop num1 = var "Hi". 1 = var num2 Alert (num1-num2);
A Hi
B. 1
C NaN3
D being given
correct answer: C
Analysis:
for Number () Hermit conversion, are converted digital, num1 is not a numeric string is converted to NaN

24.HTML page when writing JavaScript, HTML will use a label, which is
A Script
B style
C Link
D body
the correct answer: A
resolution:

25. The following code, what will pop num1 = var "Hi". 1 = var num2 Alert (num1 num2 +);
A Hi1
B. 1
C Hi
D being given
the correct Answer: A
Resolution:
string concatenation

28. In the following code, what will pop num1 = var ". 1"; var. 1 num2 = Alert (num1-num2);
A 0
B. 11
C. 1. 1 +
D being given
the correct Answer: A
Resolution:

Subtraction, a recluse conversion, all numbers

Score: 2
29.var num = 123.456789; which method can be three decimal places
A num.toString (. 3)
B num.toFixed (. 3)
C parseFloat (NUM,. 3)
D Number The (NUM,. 3)
the correct answer: B
analysis:
Note that only the value of the variable type, the method only toFixed

Score: 2
output code is 30. 10 = SUM var; for (var = I 2; I <10; I ++) {SUM = SUM + 0.05 * SUM;} Alert (the parseInt (SUM));
A . 11
B 12 is
C 13 is
D 14
correct answer: D
Analysis:

10 * Math.pow (1.05,8) = 14.7745 ... rounded to 14

Second, multiple choice (a total of 20 items, each of 2 points)
Score: 2
1. The following is a loop which
A the while
B do ... the while
C for
D Switch
correct answer: A, B, C
parsing:
the while, do ... while, for

2. Which of the following structure belonging to the selected control statements:
A IF
B for
C Switch
D the while
the correct answer: A, C
Analysis:
fixed keywords

3. The following data type options are digital type
A ". 1"
B. 1
C true
D NaN3
correct answer: B, D
resolved:
. 1, NaN3
have been 4. The following statement is true of the
A "1" == 1
===. 1 B ". 1"
C "2"> ". 19"
D "2". 19 ==
correct answer: A, C
Analysis:
comparison of the equal sign will be equal to two implicit type conversion, only values are equal to , three types of the equal sign and value must at the same time the result was equal to true, so the error A to B

String comparison between the size of the coding size is in accordance ACSII, "2" than the ASCII code "1" in ASCII large, the correct C

Numeric string comparison with the size of the string is implicitly converted to a digital, ie 2> 19, D option error

The following statement is obtained with a number 2 is
A +. 1 '. 1'
B. 8% '. 3'
C '. 1' + '. 1'
D '. 4' - 2
correct answer: B, D
Analytical:
A is the string concatenation , the result is: "11"; B "3 " are implicitly converted 3-bit, the result is 8% 3 = 2; C is a string concatenation, the result is "11"; D "4" are implicitly converted to 4, the result is 4-2 = 2 therefore, the answer to BD

6. Which of the following is a keyword
A var
B function
C Case
D above are keywords
correct answer: A, B, C, D
resolved:
var keyword variable declaration; function declaration of the function key; case of selecting branches key word

So the answer is ABCD

7. The following is the basic data type is JavaScript
A Object
B Number
C String
D Boolean
correct answer: B, C, D
parsing:
Object reference type

8. What are the program structure
A sequence structure
B selective structure
C of the cyclic structure
D None of the above
correct answer: A, B, C
Analysis:
program structure sequential structure, selection structure and loop structure

9.switch statement can contain the following keywords What?
Case A
B the else
C BREAK
D default
correct answer: A, C, D
resolved:
the else determining if a keyword is

10. The loop of the following are
A Switch
B for
C the while
D ... do the while
correct answer: B, C, D
Analysis:
loop three for while do ... while; switch configuration is selected

11. The following variable naming right is
A $ NUM
B 1num
C NUM
D num1
correct answer: A, C, D
Analysis:
variable name can not start with a number

12. Which of the following methods may be implemented string "123" into numeric
A Number The ()
B the parseInt ()
C parseFloat ()
D Boolean ()
the correct answer: A, B, C
parsing:
Boolean () is a data types into Boolean;

13. Which of the following types of data belong to the basic
A Object
B Boolean
C String
D Number
correct answer: B, C, D
parsing:
null is undefined and specific data type;

14. Which of the following Boolean
A 0
B. 1
C false
D true
correct answer: C, D
Analysis:
Boolean values true and false only two

15. The argument function may be
A constant
B variable
C is the only variable
D is constant only
correct answer: A, B
analysis:
argument variables may be constant, variable parameter is the only

16.javascript which of these components by the
A JS
B the ECMAScript
C the DOM
D the BOM
correct answer: B, C, D
resolved:
the BCD

17. declare variables and assign the following written right there
A var _myName 12a =
B = var _myName "12a"
C myName var = 12
D = var $ myName to true
correct answer: B, C, D
parsing:
A character 12a options string, is not a pure number, string use quotation marks

18. Which of the following methods may be implemented string "123" into numeric
A Number The ()
B the parseInt ()
C parseFloat ()
D Boolean ()
the correct answer: A, B, C
parsing:
Boolean () converted to Boolean value

19. The meaning of the recursive function
A call to a function by name constituted under its own case
B will function inside the function call itself
one kind of flow control statements used in C
D structure is to choose
the correct answer: A, B
analysis:
recursive calls itself is, but not flow control statements, we can not control visibility, right AB, CD error

20. Which of the following is a logical operator?
&& A
B ||
C!
D None of the above
correct answer: A, B, C
Analysis:
Logical Operators

Guess you like

Origin blog.csdn.net/ZHANGJIN9546/article/details/93670094