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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:39:41+00:00 2026-06-07T20:39:41+00:00

Looking at Google’s code for their bookmark bubble library, I came across this: var

  • 0

Looking at Google’s code for their bookmark bubble library, I came across this:

var google = google || {};
google.bookmarkbubble = google.bookmarkbubble || {};

Could someone explain what it is they’re doing here and why they are doing it? Since JS is an interpreted language why would you ever need to assign the same google object into the google variable? Wouldn’t the script this is contained in only get executed once each time a page is loaded?

  • 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-07T20:39:43+00:00Added an answer on June 7, 2026 at 8:39 pm

    They are setting up a namespace-like object. In case there is already a google object or google.bookmarkbubble object, they are making sure they don’t replace it. For example, if you had another Google library added, it may have already set up a google object that looks like this:

    {
        somelibrary: {
            ...
        }
    }
    

    So if they just had:

    var google = { bookmarkbubble: { ... } }
    

    That would break any code that referenced google.somelibrary. Likewise, if they didn’t have var google = google || {}; and you didn’t have google already defined, then google.bookmarkbubble would throw an error.

    In short, this code ensures that a google.bookmarkbubble object exists without overwriting any previously-defined google or google.bookmarkbubble objects.

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

Sidebar

Related Questions

I'm new to jquery and I'm looking at google's code to create their 'More'
I've been looking at google and nothing really points to this problem. When I
I'm looking at Google App Engine Django on google code but the latest release
I've been looking on google about this but I can't find a clear answer.
I have been looking through Google and SO for something that could help me
If you came here from Google looking for model to dict, skip my question,
QUICK ANSWER : For those of you who reach this page via Google looking
I am looking at google calendar and wondering how they did their reminders. Currently
In this question , I got the following answer: Looking at Google's maps script
I've searched everywhere for a solution to this...even Google's own code example doesn't work.

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.