GkSeries.com

JavaScript Questions & Answers – Closures | JavaScript Multiple Choice Questions and Answers

(1) What kind of scoping does JavaScript use?
[A] Literal
[B] Lexical
[C] Segmental
[D] Sequential
Answer: Lexical
(2) What must be done in order to implement Lexical Scoping?
[A] Get the object
[B] Dereference the current scope chain
[C] Reference the current scope chain
[D] Return the value
Answer: Reference the current scope chain

DOWNLOAD CURRENT AFFAIRS PDF FROM APP

(3) What is closure?
[A] Function objects
[B] Scope where function’s variables are resolved
[C] Both Function objects and Scope where function’s variables are resolved
[D] Function return value
Answer: Both Function objects and Scope where function’s variables are resolved
(4) Which of the following is not an example of closures?
[A] Objects
[B] Variables
[C] Functions
[D] Graphics
Answer: Graphics
(5) Which of the following uses a lot of CPU cycles?
[A] GUI
[B] Statically generated graphics
[C] Dynamically generated graphics
[D] Generic scoping
Answer: Dynamically generated graphics
(6) What will be the function of the following JavaScript code?
var scope = "global scope";
function checkscope() 
{
    var scope = "local scope"; 
    function f() 
    { 
         return scope; 
    }
    return f;
}
[A] Returns value null
[B] Returns exception
[C] Returns the value in scope
[D] Shows an error message
Answer: Returns the value in scope
(7) What is the fundamental rule of lexical scoping?
[A] Functions are declared in the scope
[B] Functions are executed using scope chain
[C] Functions are declared outside the scope
[D] Variables are declared within the function
Answer: Functions are executed using scope chain
(8) What is the opposite approach to the lexical scoping?
[A] Literal scoping
[B] Static scoping
[C] Dynamic scoping
[D] Generic scoping
Answer: Dynamic scoping
(9) What is the purpose of the dynamic scoping?
[A] Variables can be declared outside the scope
[B] Variables must be declared outside the scope
[C] Variables cannot be declared outside the scope
[D] Variable cannot be declared within the function
Answer: Variables can be declared outside the scope
(10) Which of the algorithmic languages is not lexical scoping standardized in?
[A] Ada
[B] Pascal
[C] Modula2
[D] Html
Answer: Html

Please share this page

Click Here to Read more questions

Teacher Eligibility Test