Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="This bin is an example of calling async methods with a callback x number of times in a loop">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
function add(x, y, callback) {
  return callback(x + y);
}
function subtract(x, y, callback) {
  return callback(x - y);
}
var x = 1,
    y = 2;
add(x, y, function (result) {
  subtract(result, x, function (result) {
    add(result, y, function (result) {
      subtract(result, y, function (result) {
        add(result, x, function (result) {
          console.log(result);
        });
      });
    });
  });
});
console.log("before or after?");
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
jlaustillpro
0viewers