0 Favourites

Problem understanding .obj vs ["obj"]

  • 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
  • Construct 3

    Buy Construct 3

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

    Buy 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)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
Understanding subscription
96 4,814
ruskul's avatar
ruskul
Unread hot topic
98 7,601
norum82's avatar
norum82
Unread hot topic
87 5,378
facecjf's avatar
facecjf