Question: $(document).ready(function() { var createClickCounter = function() { var count = 0; var clickCounter = function() { count++; console.log(this.id + + count is +

$(document).ready(function() { var createClickCounter = function() { var count = 0; var clickCounter = function() { count++; console.log(this.id + " + count is " + count); }; return clickCounter; }; $("btnCount").click( createClickCounter() ); });

(Refer to code example 18-1) Why is there a pair of parentheses after createClickCounter in the statement that attaches the handler for the click event of the button?

a.

So the outer and inner functions are executed.

b.

So the outer function runs and returns the definition of the inner function as the event handler.

c.

Because this is the standard notation for closures.

d.

Because its an immediately invoked function expression.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!