Created
November 23, 2015 11:39
-
-
Save Vannevelj/83b1e4329ef95500f976 to your computer and use it in GitHub Desktop.
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 doReplaceASync() { | |
const input = 'haha'; | |
const result = input.replace(/a/g, function() { | |
let result; | |
myAsyncFunc(function(err, data) { | |
result = data; | |
}); | |
return result; | |
}); | |
console.log(result); | |
}; | |
function myAsyncFunc(cb) { | |
let total = 5; | |
for(let i = 0; i < 1000000; i++){ | |
total++; | |
} | |
cb(null, 'e'); | |
} | |
doReplaceASync(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment