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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:54:35+00:00 2026-05-11T11:54:35+00:00

function Foo(f) { var f = f; } Here inside the function, variable f

  • 0
function Foo(f) {    var f = f;     } 

Here inside the function, variable f is local to the Foo (it has a function scope), but why is the variable f in the argument list not in conflict? Maybe because it is bound inside the Foo.arguments object?

In other languages we cannot declare an argument variable with the same name as a local variable.

How is this name ambiguity resolved? Or, How do you reference each of the two distinct f variables later in the method?

  • 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. 2026-05-11T11:54:35+00:00Added an answer on May 11, 2026 at 11:54 am

    JavaScript does a couple of things that aren’t obviously intuitive – the one you’re interested in is called ‘hoisting’ – JS moves var declarations to the top of a function, where they serve the sole purpose of reserving this variable name as a local variable in the function’s scope. Sometimes, this leads to lots of weirdness. If the variable name is already reserved as a local variable (e.g. it’s an argument) the var declaration gets dropped entirely.

    Another unintuitive part of JS is how it deals with argument variables and the arguments object (which are a bit special, as Hippo showed). That’s not necessarily what you’re interested in, though – what’s important for your example is that arguments also declare that variable name as local to the function.

    The result of all this is that when you have a var f as well as an argument name f, the `var f’ gets dropped, and your example is equivalent to:

    function Foo(f) {    f = f; } 

    You can see this in Hippo’s example, because:

    function foo(f) {     console.log(f); // --> 11     console.log(arguments); // --> array [11]     var f = 10;     console.log(f); // --> 10     console.log(arguments); // --> [10] (!!!) } 

    Is equivalent to:

    function foo(f) {     var f;     console.log(f); // --> 11     console.log(arguments); // --> array [11]     f = 10;     console.log(f); // --> 10     console.log(arguments); // --> [10] (!!!) } 

    Is equivalent to:

    function foo(f) {     console.log(f); // --> 11     console.log(arguments); // --> array [11]     f = 10;     console.log(f); // --> 10     console.log(arguments); // --> [10] (!!!) } 

    For more details, read up section 10.1.3 – Variable Instantiation (bottom of p.37) in ECMA-262, the JS specification.

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

Sidebar

Ask A Question

Stats

  • Questions 85k
  • Answers 85k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer $filename =~ s%/[^/]*$%/newfilename.txt%; s%...%...% - use % as the delimiter,… May 11, 2026 at 5:10 pm
  • Editorial Team
    Editorial Team added an answer Quick find (why didn't I see if before...), the link… May 11, 2026 at 5:10 pm
  • Editorial Team
    Editorial Team added an answer I don't think this is possible. Folder membership isn't a… May 11, 2026 at 5:10 pm

Related Questions

Often I find myself filling ASP.NET repeaters with items that need the CSS class
I have the following problem using template instantiation [*]. file foo.h class Foo {
What's wrong with the following little program that passes a function object? #include <iostream>
I've trying to achieve something like this: class Base { public: Base(string S) {

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.