# Latest JavaScript Interview Questions & Answer for 2024

Published: 2024-07-01 · By Next-G Classes · Source: https://nextgclasses.com/blog/latest-javascript-interview-questions-answer-for-2024

> Here are some of the latest interview questions and answers for JavaScript. Next-G Classes is one of the best institutes for IT courses in Delhi NCR, providing comprehensive training in JavaScript to help you master this essential web development language.

<p dir="ltr">JavaScript is a versatile, high-level programming language commonly used to create interactive effects within web browsers. As a core technology of the World Wide Web alongside HTML and CSS, JavaScript enables developers to implement complex features on web pages, such as dynamic content updates, interactive forms, animations, and more. Its flexibility and wide range of libraries and frameworks, like React, Angular, and Node.js, make it a powerful tool for both front-end and back-end development. JavaScript is known for its event-driven, functional, and imperative programming styles, making it a favorite among developers for creating responsive and engaging web applications.<br />Here are some interview questions :</p>
<p dir="ltr">1) Which type of JavaScript language is ___<br />a.Object-Oriented<br />b.Object-Based<br />c.Assembly-language<br />d.High-level</p>
<p dir="ltr">Answer: B</p>
<p dir="ltr">2. What is JavaScript?</p>
<p dir="ltr">a. JavaScript is a scripting language used to make the website interactive</p>
<p dir="ltr">b. JavaScript is an assembly language used to make the website interactive</p>
<p dir="ltr">c. JavaScript is a compiled language used to make the website interactive</p>
<p dir="ltr">d. None of the mentioned</p>
<p dir="ltr">Answer: a</p>
<p dir="ltr">3. The &rdquo; var&rdquo; and &ldquo;function&rdquo; are known as _____________.</p>
<p dir="ltr">a. Data types</p>
<p dir="ltr">b. Keywords</p>
<p dir="ltr">c. Prototypes</p>
<p dir="ltr">d. Declaration statements</p>
<p dir="ltr">Answer: (d) Declaration statements</p>
<p dir="ltr">4. Which of the following is correct about JavaScript?</p>
<p dir="ltr">a) JavaScript is an Object-Based language</p>
<p dir="ltr">b) JavaScript is Assembly-language</p>
<p dir="ltr">c) JavaScript is an Object-Oriented language</p>
<p dir="ltr">d) JavaScript is a High-level language</p>
<p dir="ltr">Answer: a</p>
<p dir="ltr">5) Which of the following is the correct output for the following JavaScript code:</p>
<p dir="ltr">varx=5,y=1&nbsp;&nbsp;</p>
<p dir="ltr">var obj ={ x:10}&nbsp;&nbsp;</p>
<p dir="ltr">with(obj)&nbsp;&nbsp;</p>
<p dir="ltr">{&nbsp;&nbsp;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(y)&nbsp;&nbsp;</p>
<p dir="ltr">}&nbsp; <br />a.1<br />b.Error<br />c.10<br />d.5</p>
<p dir="ltr">Answer: A</p>
<p dir="ltr">&nbsp;</p>
<p dir="ltr">6. Which of these is the correct way in which we can call the JavaScript code?</p>
<p dir="ltr">a. Triggering Event</p>
<p dir="ltr">b. Preprocessor</p>
<p dir="ltr">c. Function/Method</p>
<p dir="ltr">d. RMI</p>
<p dir="ltr">Answer: (c) Function/Method</p>
<p dir="ltr">7. Among the given statements, which statement defines closures in JavaScript?</p>
<p dir="ltr">a. JavaScript is a function that is enclosed with references to its inner function scope</p>
<p dir="ltr">b. JavaScript is a function that is enclosed with references to its lexical environment</p>
<p dir="ltr">c. JavaScript is a function that is enclosed with the object to its inner function scope</p>
<p dir="ltr">d. None of the mentioned</p>
<p dir="ltr">Answer: b</p>
<p dir="ltr">8) Which one of the following also known as Conditional Expression:<br />a.Alternative to if-else<br />b.Switch statement<br />c.If-then-else statement<br />d.immediate if</p>
<p dir="ltr">Answer: D</p>
<p dir="ltr">9. Which of these functions of the Number Object would format a number with different numbers of digits to the decimal&rsquo;s right?</p>
<p dir="ltr">a. toFixed()</p>
<p dir="ltr">b. toExponential()</p>
<p dir="ltr">c. toLocaleString()</p>
<p dir="ltr">d. toPrecision()</p>
<p dir="ltr">Answer: (a) toFixed()</p>
<p dir="ltr">10. What will be the output of the following JavaScript code snippet?</p>
<p dir="ltr">&lt;p id="demo"&gt;&lt;/p&gt;</p>
<p dir="ltr">var txt1 ="Sanfoundry_";</p>
<p dir="ltr">var txt2 ="Javascriptmcq";</p>
<p dir="ltr">document.getElementById("demo").innerHTML= txt1 + txt2;</p>
<p dir="ltr">a) error<br />b) Sanfoundry_ Javascriptmcq<br />c) undefined<br />d) Sanfoundry_Javascriptmcq</p>
<p dir="ltr">Answer: d</p>
<p dir="ltr">11) Among the following given JavaScript snipped codes, which is more efficient:</p>
<p dir="ltr">Code A</p>
<p dir="ltr">for(var number=10;number&gt;=1;number--)&nbsp;&nbsp;</p>
<p dir="ltr">{&nbsp;&nbsp;</p>
<p dir="ltr">document.writeln(number);&nbsp;&nbsp;</p>
<p dir="ltr">}&nbsp;&nbsp;</p>
<p dir="ltr">Code B</p>
<p dir="ltr">var number=10;&nbsp;&nbsp;</p>
<p dir="ltr">while(number&gt;=1)&nbsp;&nbsp;</p>
<p dir="ltr">{&nbsp;&nbsp;</p>
<p dir="ltr">document.writeln(number);&nbsp;&nbsp;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;number++;&nbsp;&nbsp;</p>
<p dir="ltr">}&nbsp; <br />a.Code 1<br />b.Code 2<br />c.Both Code 1 and Code 2<br />d.Cannot Compare</p>
<p dir="ltr">Answer: A</p>
<p dir="ltr">12. 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?</p>
<p dir="ltr">a. search()</p>
<p dir="ltr">b. substr()</p>
<p dir="ltr">c. split()</p>
<p dir="ltr">d. slice()</p>
<p dir="ltr">Answer: (b) substr()</p>
<p dir="ltr">13. What will be the output of the following JavaScript code?</p>
<p dir="ltr">&lt;p id="demo"&gt;&lt;/p&gt;</p>
<p dir="ltr">&lt;script&gt;</p>
<p dir="ltr">var js =10;</p>
<p dir="ltr">js *=5;</p>
<p dir="ltr">document.getElementById("demo").innerHTML= js;</p>
<p dir="ltr">&lt;/script&gt;</p>
<p dir="ltr">a) 10<br />b) 50<br />c) 5<br />d) Error</p>
<p dir="ltr">Answer: b</p>
<p dir="ltr">14) In JavaScript, what is a block of statement?<br />a.Conditional block<br />b.block that combines a number of statements into a single compound statement<br />c.both conditional block and a single statement<br />d.block that contains a single statement</p>
<p dir="ltr">Answer: B</p>
<p dir="ltr">15. Look at the snippets given below and check the one in which the variable &ldquo;a&rdquo; isn&rsquo;t equal to the &ldquo;NULL&rdquo;.</p>
<p dir="ltr">a. if (a!)</p>
<p dir="ltr">b. if(a!=null)</p>
<p dir="ltr">c. if(a!==null)</p>
<p dir="ltr">d. if(a!null)</p>
<p dir="ltr">Answer: (c) if(a!==null)</p>
<p dir="ltr">16. Arrays in JavaScript are defined by which of the following statements?</p>
<p dir="ltr">a) It is an ordered list of values</p>
<p dir="ltr">b) It is an ordered list of objects</p>
<p dir="ltr">c) It is an ordered list of string</p>
<p dir="ltr">d) It is an ordered list of functions</p>
<p dir="ltr">Answer: a</p>
<p dir="ltr">17) When interpreter encounters an empty statements, what it will do:<br />a.Shows a warning<br />b.Prompts to complete the statement<br />c.Throws an error<br />d.Ignores the statements</p>
<p dir="ltr">Answer: D</p>
<p dir="ltr">18. In JavaScript, what do we use for calling the expression for function definition?</p>
<p dir="ltr">a. Function literal</p>
<p dir="ltr">b. Function prototype</p>
<p dir="ltr">c. Function declaration</p>
<p dir="ltr">d. Function calling</p>
<p dir="ltr">Answer: (a) Function literal</p>
<p dir="ltr">19. What will be the output of the following JavaScript code?</p>
<p dir="ltr">// JavaScript Comparison Operators</p>
<p dir="ltr">function compare()</p>
<p dir="ltr">{</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;let a=2;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;let b=2.0;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;if(a==b)</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;returntrue;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;else</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;returnfalse;</p>
<p dir="ltr">}</p>
<p dir="ltr">a) false<br />b) true<br />c) compilation error<br />d) runtime error</p>
<p dir="ltr">Answer: b</p>
<br />
<p dir="ltr">20) The "function" and " var" are known as:<br />a.Keywords<br />b.Data types<br />c.Declaration statements<br />d.Prototypes</p>
<p dir="ltr">Answer: C</p>
<p dir="ltr">21. Which of these is used in JavaScript for calling a method or a function?</p>
<p dir="ltr">a. Functional Expression</p>
<p dir="ltr">b. Property Access Expression</p>
<p dir="ltr">c. Primary Expression</p>
<p dir="ltr">d. Invocation Expression</p>
<p dir="ltr">Answer: (d) Invocation Expression</p>
<p dir="ltr">22. What will be the output of the following JavaScript code snippet?</p>
<p dir="ltr">// JavaScript Equalto Operators</p>
<p dir="ltr">function equalto()</p>
<p dir="ltr">{</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;let num=10;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;if(num==="10")</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;returntrue;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;else</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;returnfalse;</p>
<p dir="ltr">}</p>
<p dir="ltr">a) false<br />b) true<br />c) compilation error<br />d) runtime error</p>
<p dir="ltr">Answer: a</p>
<p dir="ltr">23) In the following given syntax of the switch statement, the Expression is compared with the labels using which one of the following operators?</p>
<p dir="ltr">switch(expression)&nbsp;&nbsp;</p>
<p dir="ltr">{&nbsp;&nbsp;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;statements&nbsp;&nbsp;</p>
<p dir="ltr">}&nbsp; <br />a.===<br />b.equals<br />c.==<br />d.Equals</p>
<p dir="ltr">Answer: A</p>
<p dir="ltr">24. Which of these operators are used for checking if a specific property exists?</p>
<p dir="ltr">a. in</p>
<p dir="ltr">b. within</p>
<p dir="ltr">c. exist</p>
<p dir="ltr">d. exists</p>
<p dir="ltr">Answer: (a) in</p>
<p dir="ltr">25. Will the following JavaScript code work?</p>
<p dir="ltr">var js =(function(x){return x*x;}(10));</p>
<p dir="ltr">a) Exception will be thrown<br />b) Memory leak<br />c) Error<br />d) Yes, perfectly</p>
<p dir="ltr">Answer: d</p>
<p dir="ltr">26) What will happen, if the following JavaScript code is executed?</p>
<p dir="ltr">var count =0;&nbsp;&nbsp;</p>
<p dir="ltr">while (count &lt;10)&nbsp;&nbsp;</p>
<p dir="ltr">{&nbsp;&nbsp;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log(count);&nbsp;&nbsp;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;count++;&nbsp;&nbsp;</p>
<p dir="ltr">}&nbsp; <br />a.An error is displayed<br />b.An exception is thrown<br />c.The values of count variable are logged or stored in a particular location or storage<br />d.The value of count from 0 to 9 is displayed in the console</p>
<p dir="ltr">Answer: C</p>
<p dir="ltr">27. &ldquo;The expression that can appear legally on an assignment expression&rsquo;s left side&rdquo; is a common explanation for variables, elements of arrays, and properties of objects. These are known as __________:</p>
<p dir="ltr">a. Prototypes</p>
<p dir="ltr">b. Properties</p>
<p dir="ltr">c. Lvalue</p>
<p dir="ltr">d. Definition</p>
<p dir="ltr">Answer: (c) Lvalue</p>
<p dir="ltr">28. Which of the following is not javascript data types?</p>
<p dir="ltr">a) Null type</p>
<p dir="ltr">b) Undefined type</p>
<p dir="ltr">c) Number type</p>
<p dir="ltr">d) All of the mentioned</p>
<p dir="ltr">Answer: d</p>
<p dir="ltr">29) Which of the following is the correct output for the following JavaScript code:</p>
<p dir="ltr">Int x=8;&nbsp;&nbsp;</p>
<p dir="ltr">if(x&gt;9)&nbsp;&nbsp;</p>
<p dir="ltr">{&nbsp;&nbsp;</p>
<p dir="ltr">document.write(9);&nbsp;&nbsp;</p>
<p dir="ltr">}&nbsp;&nbsp;</p>
<p dir="ltr">else&nbsp;&nbsp;</p>
<p dir="ltr">{&nbsp;&nbsp;</p>
<p dir="ltr">document.write(x);&nbsp;&nbsp;</p>
<p dir="ltr">}&nbsp; <br />a.9<br />b.0<br />c.8<br />d.Undefined</p>
<p dir="ltr">Answer: C</p>
<p dir="ltr">30. Which of these is a correct output for the JavaScript code given below?</p>
<p dir="ltr">string X= &ldquo;Hey&rdquo;;</p>
<p dir="ltr">string Y=&rdquo;There&rdquo;;</p>
<p dir="ltr">alert(X+Y);</p>
<p dir="ltr">a. Hey There</p>
<p dir="ltr">b. Hey_There</p>
<p dir="ltr">c. HeyThere</p>
<p dir="ltr">d. undefined</p>
<p dir="ltr">Answer: (c) HeyThere</p>
<p dir="ltr">31. Where is Client-side JavaScript code is embedded within HTML documents?</p>
<p dir="ltr">a) A URL that uses the special javascript:code</p>
<p dir="ltr">b) A URL that uses the special javascript:protocol</p>
<p dir="ltr">c) A URL that uses the special javascript:encoding</p>
<p dir="ltr">d) A URL that uses the special javascript:stack</p>
<p dir="ltr">Answer: b</p>
<p dir="ltr">32) Which of the following is the correct output for the following JavaScript code:</p>
<p dir="ltr">var grade='C';&nbsp;&nbsp;</p>
<p dir="ltr">var result;&nbsp;&nbsp;</p>
<p dir="ltr">switch(grade)&nbsp;&nbsp;</p>
<p dir="ltr">{&nbsp;&nbsp;</p>
<p dir="ltr">case'A':&nbsp;&nbsp;</p>
<p dir="ltr">{&nbsp;&nbsp;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result+="10";&nbsp;&nbsp;</p>
<p dir="ltr">break;&nbsp;&nbsp;</p>
<p dir="ltr">}&nbsp;&nbsp;</p>
<p dir="ltr">case'B':&nbsp;&nbsp;</p>
<p dir="ltr">{&nbsp;&nbsp;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result+=" 9";&nbsp;&nbsp;</p>
<p dir="ltr">break;&nbsp;&nbsp;</p>
<p dir="ltr">}&nbsp;&nbsp;</p>
<p dir="ltr">case'C':&nbsp;&nbsp;</p>
<p dir="ltr">{&nbsp;&nbsp;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result+=" 8";&nbsp;&nbsp;</p>
<p dir="ltr">break;&nbsp;&nbsp;</p>
<p dir="ltr">}&nbsp;&nbsp;</p>
<p dir="ltr">default:&nbsp;&nbsp;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;result+=" 0";&nbsp;&nbsp;</p>
<p dir="ltr">}&nbsp;&nbsp;</p>
<p dir="ltr">document.write(result);&nbsp;&nbsp;</p>
<ol>
<li dir="ltr">
<p dir="ltr">10</p>
</li>
<li dir="ltr">
<p dir="ltr">9</p>
</li>
<li dir="ltr">
<p dir="ltr">8</p>
</li>
<li dir="ltr">
<p dir="ltr">0</p>
</li>
</ol>
<p dir="ltr">Answer: C</p>
<p dir="ltr">33. Which of these is known as the Equality operator used for checking whether both the values are equal?</p>
<p dir="ltr">a. =</p>
<p dir="ltr">b. ==</p>
<p dir="ltr">c. ===</p>
<p dir="ltr">d. &amp;&amp;</p>
<p dir="ltr">Answer: (b) ==</p>
<p dir="ltr">34. What will be the output of the following JavaScript code snippet?</p>
<p dir="ltr">int a=1;</p>
<p dir="ltr">if(a!=null)// JavaScript not equal to Operators</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;return1;</p>
<p dir="ltr">else</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;return0;</p>
<p dir="ltr">a) 0<br />b) 1<br />c) compiler error<br />d) runtime error</p>
<p dir="ltr">Answer: b</p>
<p dir="ltr">35) Which of the following is the correct output for the following JavaScript code:</p>
<p dir="ltr">var grade='D';&nbsp;&nbsp;</p>
<p dir="ltr">var result;&nbsp;&nbsp;</p>
<p dir="ltr">switch(grade)&nbsp;&nbsp;</p>
<p dir="ltr">{&nbsp;&nbsp;</p>
<p dir="ltr">case'A':&nbsp;&nbsp;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result+="10";&nbsp;&nbsp;</p>
<p dir="ltr">case'B':&nbsp;&nbsp;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result+=" 9";&nbsp;&nbsp;</p>
<p dir="ltr">case'C':&nbsp;&nbsp;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result+=" 8";&nbsp;&nbsp;</p>
<p dir="ltr">case 'D'&nbsp;&nbsp;</p>
<p dir="ltr">result+=" 6";&nbsp;&nbsp;</p>
<p dir="ltr">default:&nbsp;&nbsp;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result+=" 0";&nbsp;&nbsp;</p>
<p dir="ltr">}&nbsp;&nbsp;</p>
<p dir="ltr">document.write(result);&nbsp; <br />a.10<br />b.6<br />c.33<br />d.0</p>
<p dir="ltr">Answer: B</p>
<p dir="ltr">36. In case a value of an operator is NULL, then the unary operator would return the ____________ typeof.</p>
<p dir="ltr">a. object</p>
<p dir="ltr">b. boolean</p>
<p dir="ltr">c. string</p>
<p dir="ltr">d. undefined</p>
<p dir="ltr">Answer: (d) undefined</p>
<p dir="ltr">37. Which of the following object is the main entry point to all client-side JavaScript features and APIs?</p>
<p dir="ltr">a) Position</p>
<p dir="ltr">b) Window</p>
<p dir="ltr">c) Standard</p>
<p dir="ltr">d) Location</p>
<p dir="ltr">Answer: b</p>
<p dir="ltr">38) Which of the following is the correct output for the following JavaScript code:</p>
<p dir="ltr">var x=3;&nbsp;&nbsp;</p>
<p dir="ltr">var y=2;&nbsp;&nbsp;</p>
<p dir="ltr">var z=0;&nbsp;&nbsp;</p>
<p dir="ltr">If(x==y)&nbsp;&nbsp;</p>
<p dir="ltr">document.write(x);&nbsp;&nbsp;</p>
<p dir="ltr">elseif(x==y)&nbsp;&nbsp;</p>
<p dir="ltr">document.write(x);&nbsp;&nbsp;</p>
<p dir="ltr">else&nbsp;&nbsp;</p>
<p dir="ltr">document.write(z);&nbsp; <br />a.3<br />b.0<br />c.Error<br />d.2</p>
<p dir="ltr">Answer: B</p>
<p dir="ltr">39. Which of these is not a keyword?</p>
<p dir="ltr">a. debugger</p>
<p dir="ltr">b. use strict</p>
<p dir="ltr">c. with</p>
<p dir="ltr">d. if</p>
<p dir="ltr">Answer: (b) use strict</p>
<p dir="ltr">40. Which of these symbols is used to create comments in JavaScript?</p>
<p dir="ltr">a. //</p>
<p dir="ltr">b. \\</p>
<p dir="ltr">c. \* */</p>
<p dir="ltr">d. \* *\</p>
<p dir="ltr">Answer: (a) //</p>
<p dir="ltr">41. In the line of code given below, what will the &ldquo;datatype&rdquo; written in brackets be called?</p>
<p dir="ltr">article[datatype]=assignment_value;</p>
<p dir="ltr">a. An object</p>
<p dir="ltr">b. A String</p>
<p dir="ltr">c. Floating point</p>
<p dir="ltr">d. An integer</p>
<p dir="ltr">Answer: (b) A String</p>
<p dir="ltr">42. What will be the output of the following JavaScript program?</p>
<p dir="ltr">function sanfoundry(javascript)</p>
<p dir="ltr">{</p>
<p dir="ltr">return(javascript ?&nbsp; &ldquo;yes&rdquo; :&nbsp; &ldquo;no&rdquo;);</p>
<p dir="ltr">}</p>
<p dir="ltr">bool ans=true;</p>
<p dir="ltr">console.log(sanfoundry(ans));</p>
<p dir="ltr">a) Compilation error<br />b) Runtime error<br />c) Yes<br />d) No<br />Answer: c</p>
<p dir="ltr">43. What will be the output of the following JavaScript code?</p>
<p dir="ltr">// Javascript code snippet to compare the height</p>
<p dir="ltr">function height()</p>
<p dir="ltr">{</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp; height =123.56;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;var type =(height&gt;=190)?"tall":"short";</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;return type;</p>
<p dir="ltr">}</p>
<p dir="ltr">a) short<br />b) 123.56<br />c) tall<br />d) 190</p>
<p dir="ltr">Answer: a</p>
<p dir="ltr">44) Which of the following is the correct output for the following JavaScript code:</p>
<p dir="ltr">var grade='Z';&nbsp;&nbsp;</p>
<p dir="ltr">var result;&nbsp;&nbsp;</p>
<p dir="ltr">switch(grade)&nbsp;&nbsp;</p>
<p dir="ltr">{&nbsp;&nbsp;</p>
<p dir="ltr">case'A':&nbsp;&nbsp;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result+="10";&nbsp;&nbsp;</p>
<p dir="ltr">case'B':&nbsp;&nbsp;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result+=" 9";&nbsp;&nbsp;</p>
<p dir="ltr">case'C':&nbsp;&nbsp;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result+=" 8";&nbsp;&nbsp;</p>
<p dir="ltr">default:&nbsp;&nbsp;</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result+=" 0";&nbsp;&nbsp;</p>
<p dir="ltr">}&nbsp;&nbsp;</p>
<p dir="ltr">document.write(result);&nbsp;&nbsp;</p>
<ol>
<li dir="ltr">
<p dir="ltr">10</p>
</li>
<li dir="ltr">
<p dir="ltr">17</p>
</li>
<li dir="ltr">
<p dir="ltr">18</p>
</li>
<li dir="ltr">
<p dir="ltr">0</p>
</li>
</ol>
<p dir="ltr">Answer: D</p>
<p dir="ltr">45. Which of these codes is equivalent to the code given below?</p>
<p dir="ltr">a.x(g,h);</p>
<p dir="ltr">a. a [ &ldquo;x&rdquo; ] ( g , h );</p>
<p dir="ltr">b. x (g) &amp;&amp;a.x (h);</p>
<p dir="ltr">c. x( g&amp;&amp;h );</p>
<p dir="ltr">d. a (x )[ &ldquo;g&rdquo; , &ldquo;h&rdquo; ];</p>
<p dir="ltr">Answer: (a) a [ &ldquo;x&rdquo; ] ( g , h );</p>
<p dir="ltr">46. Which of these keywords is used to define various functions in JavaScript?</p>
<p dir="ltr">a. function</p>
<p dir="ltr">b. main</p>
<p dir="ltr">c. init</p>
<p dir="ltr">d. Void</p>
<p dir="ltr">Answer: (a) function</p>
<p dir="ltr">47) Which one of the following is the correct way for calling the JavaScript code?</p>
<ol>
<li dir="ltr">
<p dir="ltr">Preprocessor</p>
</li>
<li dir="ltr">
<p dir="ltr">Triggering Event</p>
</li>
<li dir="ltr">
<p dir="ltr">RMI</p>
</li>
<li dir="ltr">
<p dir="ltr">Function/Method</p>
</li>
</ol>
<p dir="ltr">Answer: D</p>
<p dir="ltr">48. What will be the output of the following JavaScript function?</p>
<p dir="ltr">&lt;p id="demo"&gt;&lt;/p&gt;<br />&lt;script&gt;</p>
<p dir="ltr">function javascript()&nbsp;</p>
<p dir="ltr">{</p>
<p dir="ltr">// javacript abs() method</p>
<p dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;document.getElementById("demo").innerHTML= Math.abs(-7.25);</p>
<p dir="ltr">}</p>
<p dir="ltr">&lt;/script&gt;</p>
<p dir="ltr">a) -7.25<br />b) 7.25<br />c) -7<br />d) 7</p>
<p dir="ltr">Answer: b</p>
<p dir="ltr">49. Which of the following scoping type does JavaScript use?</p>
<p dir="ltr">a) Sequential</p>
<p dir="ltr">b) Segmental</p>
<p dir="ltr">c) Lexical</p>
<p dir="ltr">d) Literal</p>
<p dir="ltr">Answer: c</p>
<p dir="ltr">50. What is the basic difference between JavaScript and Java?</p>
<p dir="ltr">a) Functions are considered as fields</p>
<p dir="ltr">b) Functions are values, and there is no hard distinction between methods and fields</p>
<p dir="ltr">c) Variables are specific</p>
<p dir="ltr">d) There is no difference</p>
<p dir="ltr">Answer: b</p>
<p dir="ltr">&nbsp;</p>
