Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Callbacks</title>
- </head>
- <script type="text/javascript">
- function q(string, pFunction)
- {
- console.log(string);
- console.log("userData is a function.");
- console.log(pFunction.toString());
- pFunction(alert); // Run the function.
- }
- q ("String.", function (callback1) // Define the function.
- {
- console.log("Doing something.");
- callback1("Alert 1!");
- }
- );
- // This does the same.
- function function1 (callback1) // Define the function.
- {
- console.log("Doing something.");
- callback1("Alert 2!");
- }
- function1(alert); // Run the function.
- </script>
- <body>
- Body.
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement