What is a prototype?


#1

Hey, when looking over the MDN documention and Angular stuff, (later), I encounter the word prototype and classes a lot. Can anyone explain what they are? ie. string.prototype?



Replace this line with your code. 



#2

The String.prototype property represents the String prototype object.

Class declarations:

One way to define a class is using a class declaration. To declare a class, you use the class keyword with the name of the class (“Rectangle” here).

class Rectangle {
  constructor(height, width) {
    this.height = height;
    this.width = width;
  }
}

#3

That is explanatory, but doesn’t give me the definition of what a class, or an instance is. I presume prototype is your specific use case, a generic term.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.