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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:45:59+00:00 2026-06-12T16:45:59+00:00

The following code is from ‘JavaScript by Example Second Edition’,I think the code below

  • 0

The following code is from ‘JavaScript by Example Second Edition’,I think the code below is better

function scroller() {
    str = str.substring(1, str.length) + str.substring(0, 1);
    document.title = str;
    window.status = str;
}
setInterval(scroller, 300);

The old code is recursive and will continue to call itself every 0.3 seconds until the program ends, I think the old code maybe cause stack overflow, right?

<html>
<!-- This script is a modification of a free script found at
the JavaScript source.
Author: Asif Nasir (Asifnasir@yahoo.com)
-->
<head>
    <script type="text/javascript">
        var today = new Date();
        var year = today.getFullYear();
        var future = new Date("December 25, " + year);
        var diff = future.getTime() - today.getTime();
        // Number of milliseconds
        var days = Math.floor(diff / (1000 * 60 * 60 * 24));
        // Convert to days
        var str =
         "Only " + days + " shopping days left until Christmas!";
        function scroller() {
            str = str.substring(1, str.length) + str.substring(0, 1);
            document.title = str;
            window.status = str;
            setTimeout(scroller, 300); // Set the timer
        } 
    </script>
</head>
<body onload="scroller()">
    <b>
        <font color="green" size="4">
Get Dizzy. Watch the title bar and the status bar!!
<br />
<image src="christmasscene.bmp">
</font>
</body>
</html>
  • 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-12T16:46:00+00:00Added an answer on June 12, 2026 at 4:46 pm

    setInterval is good if you don’t care too much about accuracy, e.g. polling for some condition to be met.

    setTimeout is good if you want a one–off event or need to adjust the interval between calls, e.g. a clock that should update as close as possible to just after the next whole second.

    Both can be used for events that run continuously at approximately the specified interval, both can be cancelled, both only run at about (as soon as possible after) the designated time interval.

    Incidentally, the first code example in the OP should not cause a stack overflow, though it is otherwise not very well written.

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

Sidebar

Related Questions

I'm converting the following code from C# to C, and I don't think I'm
Following example code from the libpcap documentation yields the following code which should report
Given the following code from a Microsoft example: public class EngineMeasurementCollection : Collection<EngineMeasurement> {
Take this following code from an example HR system. The user has the ability
In the following code (from Apple example pages) - (void)showCustomDialog: (NSWindow *)window // User
Take for example following code from a class: public class Employee : IEntity {
I'm using the following code from Apple's SimpleTextInput example to determine the frame for
I understand all of the following code from an example on a book I'm
the following code (from a database object created for each new view): -(void)update:(NSString *)queryText{
I have the following code: from random import randint,choice add=lambda x:lambda y:x+y sub=lambda x:lambda

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.