Advertisement
dwhitzzz

Override Function JS keeping Original

Nov 28th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //https://jsfiddle.net/9n9y2soc/1/
  2. //https://jsfiddle.net/bz5yhgza/
  3.  
  4. //pre esistent function
  5. function deleteCob(id){
  6.     console.log("deleteCob - id:"+id)
  7. }
  8.  
  9. //get the function
  10. var common_deleteCob = typeof deleteCob !== "undefined" ? deleteCob : function() {
  11. };
  12.  
  13. //override it
  14. deleteCob = function(idCoob){
  15.     myFunction();
  16.     common_deleteCob(idCoob);
  17. }
  18.  
  19. //our new function
  20. function myFunction(){
  21.     console.log("myFunction");
  22. }
  23.  
  24. ///then call it
  25. deleteCob(234);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement