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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top