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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:34:43+00:00 2026-06-18T22:34:43+00:00

I am defining a simple object Browser which is allowing to display previous and

  • 0

I am defining a simple object “Browser” which is allowing to display “previous” and “next” image from a list.

function Browser(image, elements) {
    this.current = 0;
    this.image = image;
    this.elements = elements;
}
Browser.prototype.next = function () {
    if (++this.current >= this.elements.length) {
         this.current = 0;
    }
    return this.show(this.current);
};
Browser.prototype.prev = function () {
    if (--this.current < 0) {
        this.current = this.elements.length - 1;
    }
    return this.show(this.current);
};
Browser.prototype.show = function (current) {
    this.image.src = this.elements[current];
    return false;
};

This code is almost liked by JSlint. But the Google Closure Compiler in “advanced optimization” does not compile it.

It says:

JSC_USED_GLOBAL_THIS: dangerous use of the global this object at line 3 character 0
this.current = 0;
JSC_USED_GLOBAL_THIS: dangerous use of the global this object at line 4 character 0
this.image = image;
JSC_USED_GLOBAL_THIS: dangerous use of the global this object at line 5 character 0
this.elements = elements;

Which tells me that I do not understand javascript oop.

What am I doing wrong?

  • 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-18T22:34:45+00:00Added an answer on June 18, 2026 at 10:34 pm

    JSC_USED_GLOBAL_THIS: dangerous use of the global this object.

    This warning means that you use the keyword this outside of prototype function or a constructor function. For example, the following code will produce this warning:

    // Produces JSC_USED_GLOBAL_THIS warning:
    this.foo = 1;
    

    In this case this actually refers to the global this object. For a standard web page, the global object is the same thing as the window object. If you get this warning, make sure that you really intended to refer to the global object.

    Note that the compiler only recognizes a function as a constructor if it is annotated with the @constructor JSDoc annotation, like this:

    /**
     * @constructor
     */
    function MyFunction() {
      this.foo = 1;
    }
    

    https://developers.google.com/closure/compiler/docs/error-ref

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

Sidebar

Related Questions

This is just a very simple question to which i can't find a good
Atleast defining my problem is simple... I have a Input control (Text) and a
What is a simple example of decorating a class by defining the decorator as
Defining infinite list in Haskell: [1,1..] => [1,1,1,..] Or, the circular way: lst=1:lst Is
Defining a form in my Play! controller when the compiler spit out this weird
When defining a custom operator from the limited set of single-character operators that can
Suppose I am defining a surface object class surface { private: vector<point> points_; vector<hexFace>
One simple way to add some configuration is to define a configuration section which
I think this is a pretty simple question but I'm having trouble finding the
I'm borrowing the slice meaning from C++. Let's say I hava a simple POJO

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.