1)Function declaration with variable name:
var x = function (a, b) {return a * b};
2)Another type of function in JavaScript within Angular1:
var method = {
add_category: function(data, success, failure) {
$upload.upload({
url: baseUrl() + 'add_category',
data: data
}).success(success).error(failure);
},
fileupload: function(data, success, failure) {
$upload.upload({
url: baseUrl() + 'ImageUpload',
data: data
}).success(success).error(failure);
}
return method;
}
What is the difference between these two code examples? In the first method (option 1), values are assigned to one variable using var x = function(a, b). For the second code (option 2), how does it work with semicolons like fileupload: function(data, success, failure)? How is the data assigned in the fileupload variable?