Page 275 - Web_Application_v2.0_C12_Fb
P. 275
D. Assertion and Reasoning questions.
Direction: Questions 1-2, consist of two statements – Assertion (A) and Reasoning (R). Answer these questions by
selecting the appropriate option given below:
a. Both A and R are true and R is the correct explanation of A.
b. Both A and R are true but R is not the correct explanation of A.
c. A is true but R is false.
d. A is false but R is true.
1. Assertion (A): The shift() method removes the first element from an array and returns it.
Reason (R): shift() modifies the original array and shifts remaining elements to lower indexes.
Ans. a.
2. Assertion (A): Comparison operators in JavaScript always return true or false as a string.
Reason (R): JavaScript converts non-boolean values into booleans when used with comparison operators.
Ans. d.
E. Statement-based questions.
Two statements are given. Statement 1 and Statement 2. Examine the statements and answer the question according
to the instructions given below:
a. Statement 1 is True, Statement 2 is True
b. Statement 1 is False, Statement 2 is False
c. Statement 1 is True, Statement 2 is False
d. Statement 1 is False, Statement 2 is True
1. Statement 1: The pop() method removes the first element from an array.
Statement 2: The shift() method removes the first element from an array.
Ans. d.
2. Statement 1: In JavaScript, const variables can have their values reassigned after declaration.
Statement 2: var allows global-scoped variable declarations that can be reassigned.
Ans. d.
Unsolved Exercise
Section A
(Objective Type Questions)
A. Choose the correct option.
1. The correct way of using the random function is ................................
i. random() ii. RANDOM()
iii. math.random() iv. randint()
2. What will be the output of the following JavaScript code:
var names = ["Gangubai", "Tenalirama", "Motu", "Pappu"]
document.write(names.pop())
i. Gangubai ii. Pappu
iii. Tenalirama iv. Motu
3. In JavaScript code, if a variable is declared using var in a for loop it can be accessed
i. inside the loop only ii. inside the entire function
iii. inside the entire program iv. Not available at all.
JavaScript Part 2 273

