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 9219975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:14:25+00:00 2026-06-18T03:14:25+00:00

At a job interview, I was perplexed to hear javascript can evaluate statements out

  • 0

At a job interview, I was perplexed to hear “javascript can evaluate statements out of order.” To what degree is this true? I can imagine a hundred ways to explicitly evaluate statements out of order — such as in a time-sharing operating system. But he seemed to say that if I evaluate

console.log('a')
console.log('b')

that the Javascript spec somehow doesn’t require that the output would be a first then b. I can imagine that the evaluator might try to evaluate the second statement if the IO of the first is blocking if the statements are functionally pure, i.e. no side effects, but side effects must always occur in sequence, correct? And of course IO is one big side effect.

To what extent can spec-compliant Javascript evaluate out of order? Or was this a case of miscommunication?

  • 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-06-18T03:14:27+00:00Added an answer on June 18, 2026 at 3:14 am

    JavaScript is single threaded (web workers aside). Period. ECMA-262 Language Specification Edition 5.1 says nothing about out-of-order execution. In your simple example these two statements are guaranteed to be executed in the same order.

    Moreover, single block of JavaScript code will never be interrupted by any other block of code, e.g. event handler. That’s why long running blocks of code cause UI to freeze:

    for(var i = 0; i < 1000000000; ++i) {
        console.log(i);
    }
    

    It’s guaranteed that the block of code above will never be interrupted or reordered. As long as the loop is running, all event handlers and timeouts wait for single thread. And of course, numbers will appear in correct order.

    What might be executed out-of-order is an asynchronous timeout:

    setTimeout(function() {
        console.log('a');
    }, 1);
    setTimeout(function() {
        console.log('b');
    }, 1);
    

    Here you might expect a to be printed first, but it’s possible that JS engine will reorder these events. After all you schedule these calls to execute at almost the same point in time.

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

Sidebar

Related Questions

This is a question Im trying to figure out for a job pre-interview questioniar.
I was given this question at a job interview recently and couldn't figure out
This was an job placement interview I faced. They asked whether we can realloc
I have a job interview tomorrow and I'm trying to answer this question: There
I was asked this question in a job interview, and I'd like to know
I have a job interview late next week as a report developer. At this
This question was in my job interview.. I just to see whether I gave
This is for a job interview and I'd love it if someone could put
I was asked this question in a job interview recently. I answered that I
Just been asked this question as a true / false in a telephone job

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.