vendredi 10 juillet 2015

difference between two functions

What is the difference between these two functions written in javascript ?

function 1

var a, b;

this.get('obj').then(function(ob) {
    a = ob.get('prop');
}.bind(this)).then(function() {
    this.get('obj').reload();
}.bind(this)).then(function(){
    b = this.get('obj.prop')    
}.bind(this))

function 2

this.get('obj').then(function(ob) {
    a = ob.get('prop');
}.bind(this)).then(function(){
   this.get('obj').reload().then(function(){
       b = this.get('obj.prop');
   }.bind(this))
}.bind(this))

The first one is erroneous.

Aucun commentaire:

Enregistrer un commentaire