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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:14:29+00:00 2026-06-14T21:14:29+00:00

oops – incorrectly posted apologize to all. misread my code and misinterpreted its behavior.

  • 0

oops – incorrectly posted

apologize to all. misread my code and misinterpreted its behavior.


source code

have page in which variable shoe is initialized twice, once in index.html and once in an included script.js:

index.html

<script src='script.js'></script>
<script>
   var shoe = { color: 'pink' };
</script>

script.js

var shoe = { size: 13 };

resulting value

in chrome, the resulting value of shoe was

>> shoe = { color: 'pink', size: 13 }

it appears that chrome concatenated the two declarations – which is super cool
and super polite.

it this standard behavior? can I count on this between browsers?


runtime example

see http://www.trailsandtribulations.net/tech/barebone.html

the sources are:

  • http://www.trailsandtribulations.net/tech/barebone.jade
  • http://www.trailsandtribulations.net/scripts/session.js

(I have temporarily unbundled the javascript)

the variable that’s declare more than once is state

  • 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-14T21:14:31+00:00Added an answer on June 14, 2026 at 9:14 pm

    The situation in your question is actually not occurring at all (at least with version 23 of chrome). I’ll attempt to show you this is the case.

    First, ‘var state’ is declared in your ‘session.js’ with the follow attributes.

    var state = {
      inited: false,
      sid: null,
      hash: null,
      status: null,
      usr: {},
      domain: window.location.hostname.split('.').splice(-2).join('.')
    };
    

    Then within the head of your html you have a script block that declares ‘var state’ again, this overwrites the original object as it should.

    var state = {
      sources: [
        '/tech/layout.jade',
        '/scripts/bladette.js',
        '/scripts/utils.js',
        '/scripts/modal.js',
        '/scripts/session.js',
        '/scripts/outliner.js',
        '/scripts/restful.js',
        '/scripts/params.js',
        '/scripts/menu.js',
        '/scripts/checks.js',
        '/scripts/notes.js',
        '/scripts/expand.js',
        '/scripts/store.js',
        '/scripts/storage.js' ],
      initFuncs: [ session.init ]
    }
    

    After this, there are many places in your code where you are assigning values to your state object. This is why it starts to look like both objects were merged. One give away that it wasn’t is that ‘state.inited’ does not exist, yet it is declared with this property in the ‘session.js’ script. Your object is getting these properties via other functions. My advice would be to debug through your JS at different stages/events and check ‘state’ object to work out where these values are getting added. Remembering that ‘state.foo = 1;’ will give the ‘state’ object a property of ‘foo’ regardless of it being declared with it or not.

    Hope that helps.

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

Sidebar

Related Questions

I'm revising my OOPs concepts in PHP. I have a simple php code here
i have code written something like this. if(!isset($cid)) { echo <script type=\text/javascript\>alert('OOps, Something went
I have a string: Hello, my name is blah blah (goodbye) (hello) (oops) How
I am just refreshing the oops features of the java. So, I have a
Either in C# or Java or in any other language which follows oops concepts
<object id=page type=text/html data=index_test.html width=565 height=500> <p>Oops! That didn't work...</p> </object> This is what
EDIT: OOPS, sorry I wasn't clear. I have a string that I get from
I have the following code: $sql = INSERT INTO table VALUES ('', ...); $result
In this code: void Window::oops() { printf(Window oops\n); } void TextWindow::oops() { printf(TextWindow oops
I have 3 Questions regarding Oops Concepts : What is the default access modifiers

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.