Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. function add(first, second, callback) {
  2. console.log(first+second);
  3. if (callback) { //don't fire callback if it doesnt exist.
  4. callback();
  5. }
  6. }
  7.  
  8. add(2, 3, function(){
  9. console.log('done');
  10. });
  11.  
  12. add(4,5, function() {
  13. console.log('done again');
  14. });
  15.  
  16. add(4,5);
  17.  
  18.  
  19. //Jquery example
  20.  
  21. $('#myDiv'.click(function (){
  22. //function will only fire when you click.
  23. }))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement