0

I'm new in javascript.

I want to what's the difference between this

 function aa(){
    //code
}

    function bb(){
      //code
    }

and this

var b = {
        aa : function (){
    //code
      },
       bb: function () {
        //code
   }
};

I know about function. but I don't know about the another one.

What's it called and what's differences?? which one is better and faster??

Thanks in advance.

Raymond
  • 572
  • 4
  • 12
  • 26
  • possible duplicate of [JavaScript: var functionName = function() {} vs function functionName() {}](http://stackoverflow.com/questions/336859/javascript-var-functionname-function-vs-function-functionname) – Niko Mar 18 '13 at 06:58

1 Answers1

1

The first one creates two named functions: aa and bb.

The second one creates an object called b that has two properties: aa and bb, both of which have anonymous functions as values.

They do different things, so you can't really say which one is "better".

Blender
  • 257,973
  • 46
  • 399
  • 459