Crockford code regarding Invructor template

The code below is almost identical to some of the code from Douglas Crockford's book: “Good Details,” pp. 29-30. The only difference is that it adds the get_status property as follows:

Quo.prototype.get_status=function() {
  this.status=string;
}

My question is why its code is working fine, but my small change below leads to an error that says myQuo does not have a get_status method?

<script>
  var Quo=function(string) {
    this.status=string;
  }
  Quo.get_status=function() {
    return this.status;
  }
  var myQuo=new Quo("confused");
  alert(myQuo.get_status());
</script>
+5
source share
2 answers

Quo, , , new Quo(). - Quo.get_status(), , this Quo.

Quo.status = "foo";
Quo.get_status(); // "foo"
+8

- JavaScript. , . , , . , JavaScript, .

0

All Articles