mardi 23 août 2016

Understand confusingly similar javascript code snippets

Here, there are two different code snippets. I need to know what the output of each is, and why it produces that output.

var output = (function(x){
        delete x;
        return x;
      })(0);
    
      console.log(output);

var x = 1;
var output = (function(){
    delete x;
    return x;
  })();

  console.log(output);

Aucun commentaire:

Enregistrer un commentaire