JSFiddle - React, Tailwind, and code Playground

by Sudheer Nunna

JavaScript

function Person(fname,lName){
var _firstName = "unknown";
this.firstName=fname;
this.lastName = lName;
this.fullName = function(){
return this.firstName+" "+this.lastName;
}

Object.defineProperties(this,{"firstName":{
get: function(){
return _firstName;
},
set:function(value){
 _firstName = value;
}
}})
}

const var1= new Person("nss","na");
console.log(var1.firstName);
console.log(var1.fullName());