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

  • Home
  • SEARCH
  • 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 8930221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:50:21+00:00 2026-06-15T08:50:21+00:00

Here is a why does this work instead of why does this NOT work?

  • 0

Here is a “why does this work” instead of “why does this NOT work?” The movePic function updates coordinates for a couple images, and changes images as needed, then calls setTimeOut(movePic, delay). So the movePic function is called WITHIN the mnovePic function.

  1. Why does this not make an endless recursion of functions inside of functions?

  2. If the answer to #1 is that when setTimeOut calls movePic, it also first breaks out of movePic, how does the actual moving of the images, that comes AFTER setTimeOut, ever execute?

The complete page is at http://www.salemharvest.org. The function is:

function movePic ()  {
left1 += movement;
left2 += movement;
if (left1 > 500)  { //  photo1 disappears over right edge
  left1 = -510; // photo1 goes to  500 left of window
  left2=-510;  // photo2 goes to START of window 
  j=j+1;
  if (j > (p - 1)) j = 0;
  document.images.animated1.src = preLoad[j].src; // switches to photo
  }
else if (left1==0)  { // photo1 fully in window
  left2 =-1010; // photo2 goes to 510 ABSOLUTE to left of window
  j=j+1;
  if (j > (p - 1)) j = 0; 
  document.images.animated2.src = preLoad[j].src; // switches the photo
  }
setTimeout (movePic, delay);
photo1.style.left = left1 + "px"; 
photo2.style.left = left2 + "px"; 
} // end of movePic function
  • 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-15T08:50:22+00:00Added an answer on June 15, 2026 at 8:50 am

    setTimeout schedules the function to be called some time later. It does not affect, and in fact has nothing to do with, the code executing in the current call stack.

    By the time the setTimeout callback runs, the previous call already finished; it is not on the call stack.

    Therefore, you don’t get a stack overflow.

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

Sidebar

Related Questions

Here is my code, this does not work in Chrome, Safari, FF or Opera.
I tried this here: http://jsfiddle.net/92HXT/1/ but it does not work. It only works if
In this forum here , someone mentions that Entity Framework does not work with
Here's the story... I have a jQuery function that does something, this function is
I have a simple use case <div id=contentDiv> <!-- This does not work -->
What does this do? I find the example here, but other than what it
Why does this simple web service refuse to return JSON to the client? Here
What does the PCGPRLEN-1..28 means here?? Where does this 4 bit comes from? alt
Content: 1. Text is here. 20. More text. Why does this Vim search and
This is a continuation of the question here: JBoss - does app have to

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.