-2

I have this simple snippet, well not too simple that I needed to know how to make the connection or maybe a tip to tell me what code is this? appreciated. From the tags I'm assuming its one of them:

function Container(connectionString) {
  var dataFetched = true;
  var dbConnection = DbConnection(connectionString);
}

Container.prototype.getData = function () {
  if (!this.dataFetched)
    throw "Data not fetched!";

  return this.data;
}

Container.prototype.fetch = function () {
  this.dbConnection.getAllData(function (err, result) {
    if (err) {
      delete this.data;
      this.dataFetched = false;
      return false;
        } else {
          this.data = result;
          this.dataFetched = true;
          return true;
        }
      });
    }

function DbConnection(connectionString) { }
Zeeshan Hassan Memon
  • 8,105
  • 4
  • 43
  • 57
rockStar
  • 1,296
  • 12
  • 22

1 Answers1

2

That's JavaScript code.

The .prototype property in JavaScript is a major feature of JavaScript's prototypal inheritance.

Googling "JavaScript prototypal inheritance" will yield a huge number of resources. Just grabbing one from the first page, this looks like a reasonably concise summary: http://www.htmlgoodies.com/html5/tutorials/javascript-prototypical-inheritance-explained.html#fbid=ouJBLxsSAyT

VoteyDisciple
  • 37,319
  • 5
  • 97
  • 97