Skip to content

Data Structures And Algo In JS #7

@weikee94

Description

@weikee94

Intro

Defining Pseudo Class

function Building(floors) {
  this.what = "building";
  this.floors = floors;
}

var myHouse = new Building(3);
console.log(myHouse);

function Food(type) {
  this.type = type;
}

Food.prototype.countTypes = function() {
  console.log(`There are ${this.type} in total`);
};

var myLunch = new Food(3);
console.log(myLunch.countTypes());

Class Methods for all instances

Building.prototype.countFloors = function() {
  console.log(`I have ${this.floors}`);
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions