vuryour.blogg.se

What is js prototype
What is js prototype












what is js prototype

In code, this concept can sometimes be lost in the syntax. We can see how prototypal inheritance works on the basis of specifying categories within a group from least specific to most – from rectangle to square.

what is js prototype

We could not, however, construct this same concept using the square as a prototype, because there are properties of a square that do not apply to rectangles (i.e. four-sides and closed), while also adding a new feature (i.e.

what is js prototype

If we think of this as a JS program, we could say that the rectangle is a prototype to the square: the square inherits all properties of a rectangle (i.e. Let’s walk through an example of prototypical inheritance you’re likely familiar with from grade school: all squares are rectangles, but not all rectangles are squares.














What is js prototype