ExamVeda
Login
Home
31
What is a closure?
Discuss
Answer & Solution
Answer: Option C
Solution:
A combination of a function object and a scope (a set of variable bindings) in which the function’s variables are resolved is called a closure.
32
Which of the following are examples of closures?
Discuss
Answer & Solution
Answer: Option D
Solution:
Technically, all JavaScript functions are closures: they are objects, and they have a scope chain associated with them.
33
Which of the following uses a lot of CPU cycles?
Discuss
Answer & Solution
Answer: Option C
Solution:
Dynamically generating graphics from real-time data uses a lot of CPU cycles.
34
Consider the following code snippet :
var scope = "global scope";
function checkscope() {
var scope = "local scope"; 
function f() 
{ 
     return scope; 
}
return f;
What is the function of the above code snippet?
Discuss
Answer & Solution
Answer: Option C
Solution:
The above code snippet returns the value in scope.
35
What is the fundamental rule of lexical scoping?
Discuss
Answer & Solution
Answer: Option B
Solution:
The fundamental rule of lexical scoping is that the JavaScript functions are executed using the scope chain that was in effect when they were defined.
36
What is the opposite approach to the lexical scoping?
Discuss
Answer & Solution
Answer: Option C
Solution:
The opposite approach to the lexical scoping is the dynamic scoping.
37
What is the purpose of the dynamic scoping?
Discuss
Answer & Solution
Answer: Option A
Solution:
Dynamic scoping creates variables that can be called from outside the block of code in which they are defined. A variable declared in this fashion is sometimes called a public variable.
38
Which of the algorithmic languages is lexical scoping standardized in?
Discuss
Answer & Solution
Answer: Option D
Solution:
Lexical scoping is standardized in all algorithmic languages (ALGOL), such as Ada, Pascal, and Modula2. Additionally, it is used in modern functional languages like ML and Haskel.