Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function doSomething(id) {
- return new Promise(function(resolve,reject){
- setTimeout(() => {
- console.log(id+') Stage 1')
- resolve(id)
- }, Math.random()*100)
- }).then(function(data){
- setTimeout(() => console.log(data+') Stage 2'),Math.random()*100)
- })
- }
- for(var i=0;i<100;i++){
- doSomething('op'+i)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement