I don't understand this line as well
data: !!data && _.mapObject(data, ...
What is the signification of "!!" In the following JS code?
$.ajax({
type: "POST",
url: url,
dataType: "json",
async: true,
data:
!!data &&
_.mapObject(data, function(value) {
return $.toJSON(value);
}),
statusCode: {
500: function() {},
},
success: function(response) {
if (_.isUndefined(response.isDocument)) {
response.isDocument = that._currentSearch.type == "document";
}
if (response && response.searchResult) {
$(response.searchResult.hits).each(function(i, item) {
item.uniqueHitId = SearchModel.generateUniqueHitId();
searchModel._cacheResult[item.uniqueHitId] = item;
});
successHandler(response, that.isFacetListFound, adaptHighlights, filters);
} else {
errorHandler("No result found", response.Error);
}
},
error: errorHandler,
});
Normally, !! casts an object to a true value if this object is defined, but in my case, the content of data after this line is :
{
message: "data is not defined"
stack: "ReferenceError: data is not defined"}
Please see this screenshot from a debug result of the execution: enter image description here