in JavaScript by
Which of the following values will be returned by the last statement in the given code?



var fun =[];  



return fun;  


var fun =constfun();  


a) 10

b) 12

c) 8

d) 9

► Click here to show 1 Answer

0 votes

Answer: C

Reason: The code given in the following question creates at least 10 closures, stores them as an array.Closures are all specified within the same function invocation, so they share access to the variable i.At the time of "constfun()" method returns 10 as the value of the variable i, all closures shares this value. So, all functions in a given array of functions return the exact same value.

Learn More with Madanswer

Related questions

0 votes
asked Mar 21 in JavaScript by rajeshsharma