Reuse identifier that is bound in a closure

A

André Hänsel

Hello group.

function f() {
v = 1;
c = function () {
w = v + 1;
};

// Is there anything I can do here so I can use a variable named "v"
later on without changing the "v" inside the closure?

v = 2;

}

Regards,
André
 
G

Gregor Kofler

André Hänsel meinte:
Hello group.

function f() {
v = 1;
c = function () {
w = v + 1;
};

// Is there anything I can do here so I can use a variable named "v"
later on without changing the "v" inside the closure?

What closure? All your v, c and w end up in the global scope.

Gregor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top