I have made this function:
var changeFilter = ( function (filterName, filterValue) {
var filters = {
"tip-oglasa": "",
"zemlja": "",
"grad": "",
"deo-grada": "",
"min-kvadrata": "",
"max-kvadrata": "",
"min-soba": "",
"max-soba": "",
"min-spratova": "",
"max-spratova": "",
"min-godina-izgradnje": "",
"max-godina-izgradnje": ""
};
return function () {
filters[filterName] = filterValue;
return filters;
};
})();
I want to have function in which object filters will be defined, and get / change it via two functions (getFilters, which will just get the filters variable and changeFilter which will change filters variable and return the result).
Is is it possible to do something like this? I don't want to make filters object public as I want to access it only via this two methods.