prototype in the JavaScript these are additional functions, variables for all instances
Class
Html
Example
<html>
<body>
<script>
// Magazin it's a class (as a function)
function Magazin() {
this.Products = []; // product array
}
// added function ShowProducts in the Magazin
Magazin.prototype.ShowProducts = function () {
alert(this.Products);
};
// Create MagazinEda
var MagazinEda = new Magazin();
MagazinEda.Products = ["Pears", "Apples", "Tomatoes"];
MagazinEda.ShowProducts(); // on the screen we will see "Pears", "Apples", "Tomatoes"
// Create MagazinOdezda
var MagazinOdezda = new Magazin();
MagazinOdezda.Products = ["Trousers", "Sweater", "Shoes"];
MagazinOdezda.ShowProducts(); // on the screen we will see "Trousers", "Sweater", "Shoes"
</script>
</body>
</html>