JSFiddle - React, Tailwind, and code Playground

JavaScript

var getPersonInstance = function (name) {

    // Those are "private" properties
    var myName = name;

    return {
        getName: function () {
            return myName
        },
        setName: function (name) {
            myName = name;
        },
        sayHello: function () {
            alert('hello! my name is ' + myName);
        }
    }    
};

var person = getPersonInstance('Juan');
alert(person.getName()); // Returns Juan
person.name = 'John' // This just sets a name in the person object, but does not change anything
person.setName('John') // Works
person.sayHello();