Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anyway to create Javascript object with "default function"? AngularJS

As you may know, AngularJS $http service is allowing to call it with/out specific function, for ex:

  1. $http(req).then(function(){...}, function(){...});

  2. $http.get('/someUrl', config).then(successCallback, errorCallback);

I would like to get some more information about the way I can implement it on my factory and generally in JS.

like image 709
Idan Gozlan Avatar asked Sep 17 '26 06:09

Idan Gozlan


1 Answers

Functions are Objects in JavaScript. This means that you can assign other properties and functions on a function.

function foo(){
   //do something
}

foo.bar = function(){
   //do something else
}
like image 96
Shreyas Avatar answered Sep 18 '26 19:09

Shreyas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!