Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
1K views

MCQ based on Java Script

Uploaded by

Farhan Mirza
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

MCQ based on Java Script

Uploaded by

Farhan Mirza
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

JavaScript Multiple-Choice Questions

1. The ” var” and “function” are known as _____________.

a. Data types

b. Keywords

c. Prototypes

ni
d. Declaration statements

Answer: (d) Declaration statements

ai
2. Which of these is the correct way in which we can call the JavaScript code?

a. Triggering Event
lS
b. Preprocessor

c. Function/Method
hi
d. RMI

Answer: (c) Function/Method


ik

3. Which of these functions of the Number Object would format a number with different
numbers of digits to the decimal’s right?
N

a. toFixed()

b. toExponential()

c. toLocaleString()

d. toPrecision()

Answer: (a) toFixed()


4. Out of the following functions of the string object, which one would return the
character in any string via the specified number of characters starting at a specified
position?

a. search()

b. substr()

c. split()

ni
d. slice()

Answer: (b) substr()

ai
5. Look at the snippets given below and check the one in which the variable “a” isn’t
equal to the “NULL”.
lS
a. if (a!)

b. if(a!=null)

c. if(a!==null)
hi

d. if(a!null)

Answer: (c) if(a!==null)


ik

6. In JavaScript, what do we use for calling the expression for function definition?
N

a. Function literal

b. Function prototype

c. Function declaration

d. Function calling

Answer: (a) Function literal


7. Which of these is used in JavaScript for calling a method or a function?

a. Functional Expression

b. Property Access Expression

c. Primary Expression

d. Invocation Expression

ni
Answer: (d) Invocation Expression

8. Which of these operators are used for checking if a specific property exists?

ai
a. in

b. within
lS
c. exist

d. exists

Answer: (a) in
hi

9. “The expression that can appear legally on an assignment expression’s left side” is a
common explanation for variables, elements of arrays, and properties of objects. These
ik

are known as __________:

a. Prototypes
N

b. Properties

c. Lvalue

d. Definition

Answer: (c) Lvalue

10. Which of these is a correct output for the JavaScript code given below?
string X= “Hey”;

string Y=”There”;

alert(X+Y);

a. Hey There

b. Hey_There

ni
c. HeyThere

d. undefined

ai
Answer: (c) HeyThere

11. Which of these is known as the Equality operator used for checking whether both
the values are equal?
lS
a. =

b. ==
hi
c. ===

d. &&
ik

Answer: (b) ==

12. In case a value of an operator is NULL, then the unary operator would return the
N

____________ typeof.

a. object

b. boolean

c. string

d. undefined
Answer: (d) undefined

13. Which of these is not a keyword?

a. debugger

b. use strict

c. with

ni
d. if

Answer: (b) use strict

ai
14. Which of these symbols is used to create comments in JavaScript?

a. //
lS
b. \\

c. \* */

d. \* *\
hi

Answer: (a) //

15. In the line of code given below, what will the “datatype” written in brackets be
ik

called?

article[datatype]=assignment_value;
N

a. An object

b. A String

c. Floating point

d. An integer
Answer: (b) A String

16. In the line of code given below, the prototype represents the _____________.

functionx(){};

a. Prototype of a function

b. Function x

ni
c. Not valid

d. A custom constructor

ai
Answer: (a) Prototype of a function

17. Which of these methods or operators are used for identifying an array?
lS
a. isarrayType()

b. ===

c. ==
hi

d. Typeof

Answer: (a) isarrayType()


ik

18. A function’s execution would stop whenever a program control would encounter the
_________ statement in the function’s body.
N

a. goto statement

b. break statement

c. continue statement

d. return statement
Answer: (d) return statement

19. Which of these codes is equivalent to the code given below?

a.x(g,h);

a. a [ “x” ] ( g , h );

b. x (g) &&a.x (h);

ni
c. x( g&&h );

d. a (x )[ “g” , “h” ];

ai
Answer: (a) a [ “x” ] ( g , h );

20. Which of these keywords is used to define various functions in JavaScript?


lS
a. function

b. main

c. init
hi

d. Void

Answer: (a) function


ik
N

Thanks & Regards


Nikhil Saini
Technical Trainer IMSEC

You might also like