Page 233 - Web Applications (803) Class 12
P. 233

10.  Write any two characteristics of a ‘typeof’ operator in JavaScript.                        [2023]
                   Ans.  In JavaScript, the typeof operator has two characteristics:
                       •   It's a unary operator, which implies it only accepts one operand. Any type of operand can be used.
                       •     It  returns  a  string  showing  the  operand's  data  type.  "number",  "string",  "boolean",  "object",  "function",
                           "undefined", and "symbol" are all valid return values.
                   11.  Differentiate between % operator and / operator in JavaScript with the help of an example.   [2023]
                   Ans.  In JavaScript, the % operator is the modulus operator, which returns the remainder of a division operation. The
                       division operator, represented by the / operator, returns the quotient of a division operation.
                       Example: 10% 3 => will give answer as 1
                       10/3 => will give answer as 3.333
                   12.  Explain parseInt() and isNaN(), giving one example of each.                                [2023]
                   Ans.  isNaN() returns a boolean if a value is not a valid number. parseInt() attempts to extract an integer from a string
                       and returns either the integer or NaN if it is unable to do so.

                       var num1 = parseInt("20"); // This will return 20
                       var num2 = parseInt("hello"); // This will return NaN
                       var num3 = isNaN(num1); // This will return false
                   13.  A java script file has ____ extension.                                                   [2022 T1]
                       (a)  .java                                   (b)  .js

                       (c)  .jscript                                (d)  .jsr
                   Ans.  (b)  .js
                   14.  Document object uses its ____ method to output some text to the page document.           [2022 T1]
                       (a)  print()                                 (b)  write()
                       (c)  display()                               (d)  cout()

                   Ans.  (b)  write()
                   15.  Identify the operators that check if the value of two operands are equal or not. If values are not equal then
                       condition becomes true.                                                                   [2022 T1]
                       (a)  ==                                      (b)  !=
                       (c)  Not equal                               (d)  Equal to
                   Ans.  (a)  ==

                   16.  Statement I: Java script is a server-side language, which means all the action occurs on the client’s (reader’s) side
                       of things. This means that no trips to the server are required for JavaScript to kick into operation, which would
                       slow down the process.                                                                    [2022 T1]
                       Statement II: JavaScript is integrated into the browsing environment, which means they can get information
                       about the browser and HTML page and modify this information, thus how things are presented on your screen?
                       Identify the correct option.
                       (a)  Only statement I is correct             (b)  Only statement II is correct
                       (c)  Both statements I and II are correct    (d)  Both statements I and II are wrong
                   Ans.  (d)  Both statements I and II are wrong
                   17.  Write the output of the following code:                                                  [2022 T2]
                       NaN + 5

                   Ans.  NaN





                                                                                          Web Scripting—JavaScript   231
   228   229   230   231   232   233   234   235   236   237   238