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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:48:05+00:00 2026-06-10T23:48:05+00:00

Could someone clarify for me please… I’ve read that creating a variable using reserved

  • 0

Could someone clarify for me please… I’ve read that creating a variable using reserved word ‘var’ makes that variable public but how can that be if the variable was created inside a function:

$('#timeIn').timepicker({ 'scrollDefaultNow': true });
    $('#timeIn').on('change', function() {
        var numIn = $('#timeIn').timepicker(('getSecondsFromMidnight'));
        var inHours = {
            hours: (numIn/86400)*24,
            getter: function() {return this.hours;}
        };
        timeIn = $('#timeIn').val();
        inArray.push(timeIn);
        events.push(timeIn);
});

In this example the variables numIn & inHours are only known within that onChange method, correct? If that is the case what would the global declaration look like? The ‘timeIn’ is globally scoped but without manipulation I only get a string representation back. What are my options for getting a computable time back as return.

  • 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-10T23:48:07+00:00Added an answer on June 10, 2026 at 11:48 pm

    JavaScript uses function scope – every variable can be seen only from within the same function or a scope higher than it.

    An implicit global variable is what happens when you use a variable without first declaring it. In compiled languages this would result in a compilation error, but javascript silently declares the variable as a property of the global object (in a browser this is the window object)

    $('#timeIn').on('change', function() {
        var numIn; // only available from inside this anonymous handler function
        ... snip ...
        timeIn = $('#timeIn').val(); // this is an implicit global since it has not been declared anywhere
        // an explicit global, for example's sake
        window.someVar = 'foo';
    });
    

    With javascript v1.7 you can also establish block scopes via the let keyword:

    let(a = 5, b = 1) {
        // a and b are scoped to this block
        console.log(a+b); // 6
    }
    console.log(a+b); // error
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone please explain why this is happening? var y = new int[]{1,2}; Console.WriteLine(y
I'm not able to understand the following multi-dimensional code. Could someone please clarify me?
Could someone please clarify for me the semantic difference between these two: self.foo =
I'm developing an iPad application using Core Data, and was hoping someone could clarify
Could someone please clarify what the code means: public abstract class BaseJobProcessor<T> : JobProcessor
I have basic understanding problem with open source and licenses. Could someone please clarify
I plan on using Sentiwordnet 3.0 for Sentiment classification. Could someone clarify as to
Ok, so I'm not quite sure the difference between these languages. Could someone clarify?
Could someone help me clarify the following conecpts, and the relationship among them ?
Could someone know where is saved path to external XML-File that contain configuration for

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.