JSFiddle - React, Tailwind, and code Playground

by Jake Overall

HTML

Checkout my <a target="_blank" href="https://boisecodeworks.com/blog/2015/03/11/prototypical-inheritance-simplified/">blog</a> to read the full tutorial on prototypical inheritance

JavaScript

var Person = function(name, age, gender){
    this.name = name;
    this.age = age;
    this.gender = gender;
};

//Notice I create the new person object here 
var me = new Person('Jake Overall', 28, 'M');

//Now we add the new method to the Person prototype
Person.prototype.sayName = function(){
    return "Hello my name is " + this.name
};

//I can now call the newly added method
//Open your console to the results
console.log(me.sayName());