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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:43:26+00:00 2026-06-03T09:43:26+00:00

I’ve been looking over the GNOME shell javascript interface and noticed the following snippet

  • 0

I’ve been looking over the GNOME shell javascript interface and noticed the following snippet (popupMenu.js for those who are interested) from the prototype of a class:

PopupSwitchMenuItem.prototype = {
    __proto__: PopupBaseMenuItem.prototype,

    _init: function(text, active, params) {
        ... (code)
    },

    ... function definitions

    get state() {
        return this._switch.state;
    },

    ... more functions
};

Could anyone explain to me what the get state() { ... } means? I thought everything had to be of the form name: value within a javascript object? (If I make one of these objects I can do obj.state which returns what I assume is this._switch.state).

It may help to note that GNOME say they use a flavour of javascript (gjs) similar to Mozilla’s Spidermonkey, so is this behaviour a non-standard javascript behaviour and a feature of spidermonkey/gjs?

Also, is there documentation pertaining to this?

  • 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-03T09:43:28+00:00Added an answer on June 3, 2026 at 9:43 am

    Check out https://developer.mozilla.org/en/JavaScript/Reference/Operators/get and John Resig’s post at http://ejohn.org/blog/javascript-getters-and-setters/

    The interesting thing is that you access the properties just like any other property, except they are dynamically created… in example

    foo = {
      get blah() {
        return "bar";
      }
    }
    
    foo.blah == "bar"
    

    Without native getters you would have to do foo.blah(). Frankly I’ve never used them simply because IE8 doesn’t support it, and the advantage is just so minor. Most commonly I can see them being useful in a situation where I started with a “dumb” property like foo.blah, and at some point later in the development cycle realized that I wanted foo.blah(), and had to do the conversion at every point, while with the getters and setters such a conversion is unneccessary, since you simply change the object definition.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

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.