Jump to content

Function Syntax? (confused about colons!)


Shofra
 Share

Recommended Posts

I'm just learning how to code with HTML5 and Phaser, so bear with me.

I've been looking at a lot of different tutorials, and I've noticed something that I'm hoping someone can explain to me.

In tutorials or examples on the Phaser site, functions are written out the way I'm used to:

function preload() {
    //stuff
}

But in some of the tutorials, functions are written like this:

preload: function() {
     //stuff
}

I've found that, at least using Intel XDK and Cordova, only the latter functions on the phone emulation.  My question is, what's the difference?  Is it Cordova that only accepts this format?  Is there anything I have to keep in mind when I'm writing functions this way?  It's just worrisome to me that I don't know why it's like this.

I've tried searching for the information, but to no avail--I can't find the right keywords to get me any information.

Thanks!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...