In various programming languages such as Java, Ruby, and others, there is often a functionality to call a function before or after a method is executed. This feature is commonly provided by the frameworks being used. For example, Jasmine (a unit-testing library) has a method called beforeEach
that runs a specified block of code before each it
block.
My question is: Is there a similar way to achieve this in AngularJS or JavaScript, so that it can be executed before calling any method within a class or factory?