Doubt about Javascript methods

0

Curiosity:

A) Is there any behavior difference between the three structures below?

1)

function Guerra() {
  war: {
    luta: function() {
      return true;
    }
  }
}

2)

function Guerra() {}
var war = new Guerra();
war.prototype.luta = function() {
  return true;
}

3)

var Guerra = function() {
  this.war = function() {
    return true;
  }
}

B) And I would also like to know, what changes in terms of behavior the structures below:

1)

var Guerra = function () {
    return true;
}

2)

function Guerra() {
    return true;
}
    
asked by anonymous 18.06.2018 / 16:53

0 answers