JSFiddle - React, Tailwind, and code Playground

by kman007_us

JavaScript

// privacy of `name` since it's in a closure
function Foo() {
    var name;
    this.getName = function() {
        return name;    
    }   
    this.setName = function(n) {
        name = n;
    }   
}

Foo.prototype.saySomething = function() { return "something"; }

var f = new Foo();
f.setName('kevin');

console.log(f.prototype);
console.log(f.saySomething());