How to override Drupal.ajax.prototype.beforeSend? I need to add my own little if's and checks in 3 functions inside 

misc/ajax.js (
  Drupal.ajax.prototype.beforeSend,
  Drupal.ajax.prototype.success,
  Drupal.ajax.prototype.error
)


How can I override them in my module? I can't find a manual and it's not in Examples for Developers. Sorry if it seems a dumb question, but I'm a php developer - I can work with js, but I'm not so fluent with it.


Can I simply write it in my module's js file?
If 2 or 3 modules needs to modify them, how to avoid conflicts?
This might be a better way: 

(function ($) {
  // Drupal's core beforeSend function
  var beforeSend = Drupal.ajax.prototype.beforeSend;
  // Add a trigger when beforeSend fires.
  Drupal.ajax.prototype.beforeSend = function(xmlhttprequest, options) {
    beforeSend.call(this, xmlhttprequest, options);
    $(document).trigger('beforeSend');
  }
})(jQuery);


https://www.drupal.org/node/1372840