JSFiddle - React, Tailwind, and code Playground
JavaScript
//this and a prototype
function Person(){
var firstName = "Chales";
var lastName = "Woodson";
//private within Person object
function getFullName(){
return firstName + ' ' + lastName;
};
//public function that returns the firstName and lastName
this.sayHello = function(){
return getFullName() + " says hi";
}
};
//this will throw an error since it tries to access a property in the this scope which isn't defined without using new
//console.log(Person.sayHello());
var newPerson = new Person();
console.log(newPerson.sayHello());