Problem understanding .obj vs ["obj"]

0 favourites
  • 2 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Hi

    I thought i understanded the difference on .obj and ["obj"], but apparently i don't fully understand.

    If you look at the screenshot. I can easily check on:

    self.response.status == "success"[/code:39prnqmf]
    That works without problems.
    But i can't do:
    [code:39prnqmf]self.errors = self.response.errors[/code:39prnqmf]
    Even if it does exist. So if i use:
    [code:39prnqmf]self.errors = self.response["errors"][/code:39prnqmf]
    It works..
    Can anyone explain this behavior ?
    EDIT 1:
    [code:39prnqmf] =[/code:39prnqmf]
    This line is working too, for some reason.
    EDIT 2:
    I found out that i had to do like this to get it to totally work:
    [code:39prnqmf]self["errors"] = self.response["errors"][/code:39prnqmf]
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • In terms of the Javascript language, and object["property"] are identical.

    In terms of the minifier, when exporting with "minify script" enabled, will be renamed to something shorter by the minifier, e.g. object.q. However object["property"] will not be renamed. So you should use object["property"] syntax for anything that should not be renamed by the minifier.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)