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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:37:50+00:00 2026-06-11T09:37:50+00:00

All of my elements which init by my jquery plugin sharing the same local

  • 0

All of my elements which init by my jquery plugin sharing the same local variable when it running. I did a test and found out because this line:

var tmp1 = tmp2 = weird_local_var = 0;

If I write like below, it does not happens

var normal_local_var = 0;

It is not because tmp1 & tmp2, just dummy var for testing. You can see the test via http://jsfiddle.net/7SeRD/. What happen?

  • 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-11T09:37:51+00:00Added an answer on June 11, 2026 at 9:37 am

    You can just change your init line to:

    var tmp1=0, tmp2=0, weird_local_var=0, normal_local_var=0;
    
    // or
    var tmp1=0; 
    var tmp2=0;
    var weird_local_var=0;
    var normal_local_var=0;
    

    EDIT: See this answer too: link.

    From it:

    var a = b = [] is equivalent to
    
    var a;
    b = [];
    a = b;
    

    What you’re doing is chaining assignments.

    You’re essentially assigning a reference to weird_local_var (whose value is 0) to tmp2, then assigning a reference to that reference (ie tmp1 -> tmp2) to tmp1.

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

Sidebar

Related Questions

I have the jquery: $(.item) which gives me all elements of class item. I
I have two LinkedLists, I'd like to move all elements which match some criteria
So $array is an array of which all elements are references. I want to
How do I select all <div> elements which do not contain any <img> elements
I set out to make a simple fade transition between 3 elements which are
I am using a jQuery plugin called Stepy , which is based of the
I have a plist containing an array with three elements all of which are
All. I have a NSMutableArray , which name is dummyPerson. And it's element is
I'm searching for a XPath expresssion, which gives me all grandchildren of an element.
I want to select all elements that have an accesskey defined on them. I

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.