Jump to content

Phaser coding question


vespercore02
 Share

Recommended Posts

Hi Sirs and Madams,

 

is their/there difference between this two type? of coding?

 

 

this one

 

function preload(){

}

function create(){

}

function update(){

}

 

and this one

 

preload: function(){

}

create: function() {

}

update: function(){

}

 

 

 

sorry i'm totally newbie on all js coding or framework

 

 

Link to comment
Share on other sites

Hi !

I guess you're talking about creating a named function :

function myLittleFunction() { ... }

VERSUS creating an anonymous function and assigning it to a variable/property :

var myLittleFunction = function() { ... }

There are several differences ; the most "visible" is that you can use a named function before its declaration, but you can't with an anonymous function.

You can find more information and pointers here :
http://stackoverflow.com/questions/336859/var-functionname-function-vs-function-functionname

Link to comment
Share on other sites

you can also make function expression with name:

var myLittleFunction = function myLittleFunction() { ... }

it helps when debugging and makes that function is visible from itself and you can write something like

var someFunction = function myLittleFunction() {  requestAnimFrame(myLittleFunction)};
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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