Problem understanding .obj vs ["obj"]

0 favourites
  • 2 posts
From the Asset Store
For problem solving, puzzles, bubbles, platforms and other adventures.
  • 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..
    
    [img="http://i.imgur.com/f6ki7i7.png"]
    
    Can anyone explain this behavior ?
    
    EDIT 1:
    [code:39prnqmf]self.data = self.response.data[/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]
    
    -Acey
  • 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, object.property and object["property"] are identical.

    In terms of the minifier, when exporting with "minify script" enabled, object.property 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)