Posted By

tennison on 09/24/10


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

bobbym245


JS callback function


 / Published in: JavaScript
 

  1. function test(f){
  2. var x = 'private var';
  3. if (typeof f == "function") f(x); else alert('no callback');
  4. }
  5.  
  6.  
  7. test(function(x){
  8. alert(x)
  9. })
  10.  
  11.  
  12. //////////
  13. function test2(){
  14. var x = 'private var';
  15. return x
  16. }
  17.  
  18. var result = test2(); // = x

Report this snippet  

You need to login to post a comment.