I do not understand such snippet of code. is there any master can help me explain that:
I already search the explanation of querystring.parse(str, [sep], [eq], [options]). However, I do not understand why there is a "= function (str){}" after it. thanks
Here is the code:
(function ()
{
'use strict';
var queryString = {};
queryString.parse = function (str) //do not know why there is a function assigned here
{
if (typeof str !== 'string')
{
return {};
}
str = str.trim().replace(/^\?/, '');
if (!str) {
return {};
}
}
});
queryStringobject would be created, have theparsemethod added, and then the entire thing would drop out of scope without being used. So the entire thing does nothing. So I've no idea why any of it exists.