I am confused about promise. I found the code below. What is the benefit of promise here. I have read about promise that it is used to avoid callback hell. Does promise provide better performance or is it just used to write the code in readable format?
var list = function (params) {
if (!params) {
params = {};
}
var deferred = $q.defer();
if (params.q) {
params.q = JSON.stringify(params.q);
}
$http.get(someurl, {params: params}).success(function (data, status, headers) {
deferred.resolve(data);
}).error(function (data, status, headers) {
deferred.reject(data);
});
return deferred.promise;
};