Created
October 18, 2015 16:47
-
-
Save melissamarima/4398bc65ab91c9771b8c to your computer and use it in GitHub Desktop.
Trying to understand JS concurrency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sum(x, cc) { | |
setTimeout(function() { | |
cc(x.l + x.r); | |
}, 100); | |
} | |
var a = { | |
l: 1, | |
r: 3 | |
}, | |
b = { | |
l: 4 | |
}; | |
var A = sum(a, function(r) { | |
sum({ | |
l: b.l, | |
r: r | |
}, print); | |
}); | |
var B = setTimeout(function() { | |
a.l = 3; | |
}, 10); | |
var C = setTimeout(function() { | |
b.l = 6; | |
}, 100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment