Skip to content

Instantly share code, notes, and snippets.

@monirshimul
Created February 20, 2020 08:46
Show Gist options
  • Select an option

  • Save monirshimul/af801ea51bb84a7ec6fc4763832f54ed to your computer and use it in GitHub Desktop.

Select an option

Save monirshimul/af801ea51bb84a7ec6fc4763832f54ed to your computer and use it in GitHub Desktop.

Revisions

  1. monirshimul created this gist Feb 20, 2020.
    38 changes: 38 additions & 0 deletions setTimeout()...some Experipent
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@

    function a(){
    for (var i = 0; i<=10; i++){
    var a = setTimeout(()=>{
    var a = 10
    },1000)
    var a = setTimeout(()=>{
    var a = 11
    },2000)
    var a = setTimeout(()=>{
    var a = 12
    },3000)

    console.log("This is from A :",a)
    }
    b()
    }


    function b(){
    for (var i = 0; i<=10; i++){
    var a = setTimeout(()=>{
    return 10
    },1000)
    var a = setTimeout(()=>{
    return 11
    },2000)
    var a = setTimeout(()=>{
    return 12
    },3000)

    console.log("This is from B :",a)
    }
    }

    a()