Javascript: what does this syntax mean (0,functionName)(functionParemeter); -
i wondering javascript file source of http://www.google.com , try understand have done there. today wondering inside files , found strange function calls. maybe silly thing have no idea , couldn't searching it.
a readable resemble of code-
var somefunction = function(somaeparamenter){ //do stuffs; return something; } var someotherthing = (0, somefunction)(oneparameter);
please excuse lack of knowledge.
edit:
source-
i'm using chrome. while in http://www.google.com page open, opened developer tool. opened sources tab , opened file https://www.google.com.bd/xjs/_/js/s/c,sb,cr,cdos,vm,tbui,mb,wobnm,cfm,abd,bihu,kp,lu,m,tnv,amcl,erh,hv,lc,ob,r,rsn,sf,sfa,shb,srl,tbpr,hsm,j,p,pcc,csi/rt=j/ver=wuw4ydif-wi.en_us./am=ga/d=1/sv=1/rs=aitrstpu52cumknqsh0was81vrm4inla_w
in viewer. file js file i've seen there. enabled "pretty print" , in line 58 you'll find defination-
_.va = function(a) { var b = typeof a; if ("object" == b) if (a) { if (a instanceof window.array) return "array"; if (a instanceof window.object) return b; var c = window.object.prototype.tostring.call(a); if ("[object window]" == c) return "object"; if ("[object array]" == c || "number" == typeof a.length && "undefined" != typeof a.splice && "undefined" != typeof a.propertyisenumerable && !a.propertyisenumerable("splice")) return "array"; if ("[object function]" == c || "undefined" != typeof a.call && "undefined" != typeof a.propertyisenumerable && !a.propertyisenumerable("call")) return "function" } else return "null"; else if ("function" == b && "undefined" == typeof a.call) return "object"; return b };
and in line 83 you'll see function called.
_.za = function(a) { return "array" == (0, _.va)(a) };
(0, somefunction)
simply returns somefunction
so equivalent to
var someotherthing = somefunction(oneparameter);
are sure typed ? if so, , if wasn't kind of obfuscation, might unfortunate result of minification. if real code little different, example (0, someobject.somefunction)
, there might use of indirect function call.
edit :
you edit confirms goal ensure this
, inside function, global object (window
in browser) , not object on va
attached (_
).
Comments
Post a Comment