javascript - difference between jquery styles -


which style fastest? when use 1 on other?

type 1:

function makemap(){     getlatlong();     draw(); } function getlatlong(){ ... } function draw(){ ... } makemap(); 

type 2:

var map = {     init: function(){ ... }     getlatlong: function(){ ... }     draw: function(){ ... } } $test = map.init() 

the better style 1 best fits solution.

in general, time '.' used reference property, performance hit; however, may small may not matter.

as speed, let's test it:

http://jsperf.com/compare-object-function-properties-vs-functions

in both chrome , ie, direct function call faster object property reference function call.


Popular posts from this blog

javascript - Js, document.getElementById("ID").innerHTML, error -

objective c - Is there a way in OCMockito to make stubs fail when an unknown method is called? -

jquery - jqGrid update specific column data with out refreshing the entire column? -