Skip to content

Instantly share code, notes, and snippets.

@khanh96le
Last active June 29, 2016 04:26
Show Gist options
  • Save khanh96le/2641fd69e0cec20adf671edddab997af to your computer and use it in GitHub Desktop.
Save khanh96le/2641fd69e0cec20adf671edddab997af to your computer and use it in GitHub Desktop.

#What the different between 3 functions below?

function Test(x) {
    console.log(x);
    var x = 10;
    console.log(x);    
}

function TestP(x) {
    return new Promise(function(fulfill, reject){
        console.log(x);
        x = 10;
        console.log(x);
    })
}

function TestP1(x) {
    return new Promise(function(fulfill, reject){
        console.log(x);
        var x = 10;
        console.log(x);    
    })
}

Test(5);

TestP(5).then();

TestP1(5).then();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment