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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:20:50+00:00 2026-06-17T19:20:50+00:00

Object literal is considered as a static object. So, object literal should contain only

  • 0

Object literal is considered as a static object.

So, object literal should contain only static variable, but in the following piece of code

var obj = {
    a : "hello",
    foo : function(){
        console.log(this.a);
        console.log(obj.a);
    }
};

I can access a, in a static way obj.a and in a non-static way this.a.

Is a a static variable?

  • 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-17T19:20:52+00:00Added an answer on June 17, 2026 at 7:20 pm

    I think you are confusing a bunch of different things.

    You’ve created an object named obj that has a field named a. That field can be accessed as obj.a (or obj['a'] if you prefer). If you arrange for some other variable to refer to obj, then it’s also available via that variable.

    One way to arrange for some other variable to point to obj is to take a field of obj which is defined as a function/closure, and invoke it using “method” syntax, as in obj.foo(). That means that inside the body of foo, for the duration of that invocation, the special variable this will refer to obj. Therefore code within that function can access obj.a via this.a.

    None of this has anything to do with static vs dynamic scope, or singletons, or “class” vs “instance” members, or any of that. It’s just an object.

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

Sidebar

Related Questions

The following code illustrates an object literal being assigned, but with no semicolon afterwards:
I have the following javascript object literal (excerpt) var foo = {hello[35]:100,goodbye[45]:42}; I have
Consider the following code. Object obj; PropertyDescriptorCollection A = TypeDescriptor.GetProperties(obj); PropertyInfo[] B = obj.GetType().GetProperties();
Here is my object literal: var obj = {key1: value1, key2: value2}; How can
Possible Duplicate: Self-references in object literal declarations var obj = { value: 10, value2:
Possible Duplicate: Self-references in object literal declarations Given this object: var OBJ = (function(){
Am I allowed to declare prototypes in an object literal? var Obj = function(){
I have object literal what I consider as base object: var obj = {
Consider the following jQuery implementation defined using an object literal... $(function() { var myObject
This is my object literal: var obj = {key1: value1}; How can I add

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.