A
A
Alexey2017-06-07 16:38:39
Node.js
Alexey, 2017-06-07 16:38:39

How to access inside Node.js anonymous function?

There is a code, while it is executed asynchronously:

var abc = 1;

io.on('connection', function (socket) {
    socket.on('connect', function(ev) { 
    // Не видно abc
    })
});

How to see abc variable inside node.js anonymous functions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
romy4, 2017-06-07
@azovl

try to make inside the first anonymous first
var abc_ = abc;
and then inside the second
var abc = abc_;
but I tell you, it is very strange that she should not be visible inside

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question