Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7064825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:52:55+00:00 2026-05-28T04:52:55+00:00

People sometimes refer the callback pattern below being asynchronous. function beAsync(msg, cb){ cb(msg); }

  • 0

People sometimes refer the callback pattern below being asynchronous.

function beAsync(msg, cb){
  cb(msg);
}

beAsync("a", function(msg){
  console.log(msg);
});

console.log("b");

What people sometime say is that beAsync allows for the rest of the code to run then the callback happens when it’s ready.

When I call beAsync and real asynchronous functions like fs.readFile initially there must be some code that runs synchronously and then something happens that allows the code after readFile rest of the code is allowed is allowed to run.

Am I correct in saying something representing the callback enters a loop at a lower level than JavaScript?

So a revision to beAsync would include a setTimeout.

function beAsync(msg, cb){
  setTimeout( function(){ cb(msg) }, 1);
}

So setTimeout and the internals of readFile can speak to a layer which JavaScript sits on?
Speaking to this lower layer is the only way to achieve non-blocking code in JavaScript?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:52:55+00:00Added an answer on May 28, 2026 at 4:52 am

    Speaking to this lower layer is the only way to achieve non-blocking
    code in JavaScript?

    That is kind of correct. Node is just one part of the equation. The framework itself makes heavy use of threads to manage things that can block, like IO. Look at

    http://www.quora.com/How-does-IO-concurrency-work-in-node-js-despite-the-whole-app-running-in-a-single-thread

    When I call beAsync and real asynchronous functions like fs.readFile
    initially there must be some code that runs synchronously and then
    something happens that allows the code after readFile rest of the code
    is allowed is allowed to run.

    That’s not very detailed, but it correct from a high level. Whenever you fire off some asynchronous work, and give the method a callback, there is work done to execute your callback with the result of the work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When asking about common undefined behavior in C , people sometimes refer to the
I have noticed that sometimes people have to use multiple versions of jQuery in
I am reading up about Encoding and Decoding and I noticed that sometimes people
In code, I sometimes see people specify constants in hex format like this: const
I sometimes have difficulties with other people who wish to solve a problem when
Sometimes I see people use http://codepad.org as a way to quickly run/test their Perl
Sometimes I hear the argument against doing things on client side using javascript. People
Sometimes, when I present a part of the software development process to certain people,
My CMS system allows people to post some SWF's on my homepage however, sometimes
I have a really cool website that allows people to upload images. Sometimes there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.