N
N
nepster-web2015-08-17 14:16:25
JavaScript
nepster-web, 2015-08-17 14:16:25

Why is undefined constantly climbing?

I work with node.js. There is this design:

var result = findUserByHash('hash', function(user){
            console.log (user);
            return user;
        });

        console.log (result);

The moment is that everything is fine inside the callback, however, when console.log (result) is called, it shows undefined .
As far as I understand, this is a feature of asynchrony?
It turns out that you need to build the code in a chain of callbacks?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2015-08-17
@nepster-web

How many fields do I have this asynchrony feature!?
Correctly understood.
It turns out that you need to build the code in a chain of callbacks?
Not necessary. (for nodejs, of course, it has its own specifics, but the general principles are the same, of course).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question