πŸ“Š JavaScript
Q. Consider the following code snippet:
What does the last statement return ?
Code:
var c = counter(), d = counter(); 
function constfuncs() 
{
    var funcs = [];
    for(var i = 0; i < 10; i++)
        funcs[i] = function() { return i; };
    return funcs;
}
var funcs = constfuncs();
funcs[5]()
  • (A) 9
  • (B) 0
  • (C) 10
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (C) 10

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
204
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Indresh Gehalot
Publisher
πŸ“ˆ
91%
Success Rate