Advertisement
Guest User

Untitled

a guest
May 19th, 2015
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function someAction(x, y, someCallback) {
  2.     return someCallback(x, y);
  3. }
  4.  
  5. function calcProduct(x, y) {
  6.     return x * y;
  7. }
  8.  
  9. function calcSum(x, y) {
  10.     return x + y;
  11. }
  12. // alerts 75, the product of 5 and 15
  13. alert(someAction(5, 15, calcProduct));
  14. // alerts 20, the sum of 5 and 15
  15. alert(someAction(5, 15, calcSum));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement