JSFiddle - React, Tailwind, and code Playground

JavaScript

// define a function (or class) called 'Person'
function Person(name){
  // add data members 'name' to 'this' pointer which points to current context
    this.name = name;
}

// define a method in 'Person' class 
Person.prototype.greet = function(otherName){
     // will return value when you call this method
    //'othername' is an argument which you passed while calling 'greet' method
    //'name' is an data memeber which you declared while creating 'Person' class
    return "Hi " + otherName + ", my name is " + this.name;
}

// create a class object
var person = new Person('Mohit');
// call its 'greet' method 
alert(person.greet('Bekk'));