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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:17:27+00:00 2026-05-28T07:17:27+00:00

Having coded JavaScript since 1996, I have a very simple issue which I could

  • 0

Having coded JavaScript since 1996, I have a very simple issue which I could not clearly prove/disprove using jsfiddle

In some JS attached to a CV I spotted some issues that I would like to verify – one of which is
multiple declaration of variable in the same function

Testing it seems it is allowed in newer browsers (OSX Chrome16 Fx 10beta) – as far as I remember it used to give errors (Netscape/Mozilla/Fx1/IE5 or so) :

function something() {
  var var1 = "";
.
/* reams of code which scrolls the first declaration off the screen 
   so the author likely forgot the var was already declared earlier 
   in the same function */
.
  var var1 = ""; // could this result in an error in some browsers?
}

My fiddle is here

  • 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-28T07:17:27+00:00Added an answer on May 28, 2026 at 7:17 am

    Not as far as I’m aware, I’ve seen javascript functions with multiple for loops each declaring their own var i for at least 6 years all without issue.

    Having looked at the spec, there seems to be nothing concrete in this area, however since (particularly global) variable name overwrites (read: clashes) has been a feature since inception I would be very surprised if a restraint upon multiple declarations was imposed.

    As it stands, I would suggest that it doesn’t show particularly good knowledge of scoping (and hoisting) in javascript, but is valid code nonetheless.

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

Sidebar

Related Questions

I'm having an issue with rails involving javascript. Basically, I have the following code:
There is a JavaScript function, of which I have zero control of the code,
I'm having a problem since I wrapped my javascript functions inside of a namespace.
Hi I am having some problems with my javascript not working in IE. That
I'm writing some JavaScript code to parse user-entered functions (for spreadsheet-like functionality). Having parsed
I'm having some trouble with the jQuery hover method. Here's the relevant JavaScript code:
I'm having some wierd behaviour in my WinForm application coded in c#. in my:
I have a few pages with an heavy javascript usage (e.g. sorting and filtering
i'm having a javascript function using jquery: my.namespace.loadSomeStuff = function() { $.get('/Services/loadStuff', function(c){ $(#stuffDiv).html(c);
I've been having a little issue with image URLs. Usually I wouldn't care about

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.