jquery - defining local variables using an object in javascript -
may silly question, wanted know if there's difference (performance wise) between following.
someobject.prototype.myfunc = function() { var = 123; var b = "something"; ... } someobject.prototype.myfunc = function() { var loc = {}; loc.a = 123; loc.b = "something"; ... }
i've been doing second way, been easier debug doing console.log(loc) , it's habit doing server side code i've been defining local structures.
as per tests done phil (http://jsperf.com/direct-variable-vs-object-property-assignment) there's noticeable difference between using direct variable assignment , object property assignment.
definitely using direct variable assignment
Comments
Post a Comment