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

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -