JSFiddle - React, Tailwind, and code Playground

by somya_kashyap3

JavaScript

function Person(name,age){
    this.name = name;
    this.age = age;
    this.method = function(){
        this.id = this.name;
        console.log(this);
    };
}
var bob = new Person("Bob", 29);
var mary = new Person("Mary", 30);
Person.prototype.method = function(){
    console.log("Object:", this);    
};
var ed = new Person("Edward", 27);
bob.method();
mary.method();
ed.method();



function Person(name,age){
    this.name = name;
    this.age = age;
}
var bob = new Person("Bob", 29);
var mary = new Person("Mary", 30);
Person.prototype.method = function(){
    this.id = this.name;
    console.log("Object:", this);    
};
var ed = new Person("Edward", 27);
bob.method();
mary.method();
ed.method();