/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function test(f){ var x = 'private var'; if (typeof f == "function") f(x); else alert('no callback'); } test(function(x){ alert(x) }) ////////// function test2(){ var x = 'private var'; return x } var result = test2(); // = x