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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:21:30+00:00 2026-05-31T05:21:30+00:00

I have seen a piece of code that I can’t figure out: for (var

  • 0

I have seen a piece of code that I can’t figure out:

for (var m in client.actorTypes[d[5]]) {
   if (m !== 'update' && m !== 'destroy' && m !== 'remove') {
      this[m] = client.actorTypes[d[5]][m];
   }
}

but actorTypes is not a 2D array:

Game.prototype.BaseActor = function(rate) {
   this.updateRate   = rate;
   this.onCreate     = function(data, complete) {};
   this.onUpdate     = function(data) {};
   this.onEvent      = function(data) {};
   this.onInterleave = function() {};
   this.onDraw       = function() {};
   this.onDestroy    = function(complete) {};
};

Game.prototype.Actor = function(id, rate) {
   return this.$.actorTypes[id] = new this.BaseActor(rate);
};

I actually don’t know what happens in this code. Can someone explain it to me? What is a this array, and how could actorTypes become a 2d array?

  • 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-05-31T05:21:31+00:00Added an answer on May 31, 2026 at 5:21 am

    Arrays have nothing to do with it.

    In Javascript, you can access object properties in one of two ways:

    1. theObject.theProperty
    2. theObject['theProperty']

    Method 1 is only possible with a literal, valid variable name; method 2 allows you to use an arbitrary expression (e.g. in your case, a string variable).

    Arrays are a special case of Javascript objects, which happen to have numerically-named properties. We use method 2 to access them because valid variable names may not start with (or be solely) numbers.

    That doesn’t mean that every time you see x[y], x must be an array, because that’s not the case at all.

    A clarifying example follows:

    var o = {
       'a': {
          'b': 5
       }
    };
    
    var x = 'a', y = 'b';
    
    console.log(o.a.b);       // Output: 5
    console.log(o['a']['b']); // Output: 5
    console.log(o[x][y]);     // Output: 5
    

    All of those three are equivalent, and o is still not an array.

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

Sidebar

Related Questions

I have seen a piece of code in the web. function isMobile() { var
I have delusions that I've seen it in some piece of code and it's
you must have seen this piece of code somewhere else too,but obviously there's no
Currently I have a piece of code that works fine as long as there
I have a ugly piece of code that adds event handlers. The problem is,
I am asking this question again. I have this piece of code that loads
I have a piece of code that requires passing a function object (functional). I
I just wondered.. I've seen that some pictures can have arguments in an url
I have seen some people in SO commenting that Singleton Pattern is an anti-pattern.
I have seen behaviour in Perforce that I am unable to explain. I took

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.