What is NotificationsService
here?
If it is a function, then the difference is that in the second case, every instance of NotificationsService
will inherit push
.
var instance = new NotificationsService();
instance.push(...);
In the first case, you simply extend NotificationsService
and it doesn't have any effect on instances created by it:
var instance = new NotificationsService();
instance.push(...); // will throw an error
NotificationsService.push(); // will work
If NotificationsService
is an object, and we assume that NotificationsService.prototype
exists and is an object, then it doesn't have anything to do with the prototype chain, you simply define the function at two different locations. This is a simpler example:
var foo = {};
var foo.prototype = {};
// defines a method on foo
foo.push = function() {...};
// defines a method on foo.prototype
foo.prototype.push = function() {...};
Those two properties don't have any relation to each other though.
To conclude: In both cases you are defining the method on different objects and as a consequence, have to be used differently. What to do depends on your use case.