Install
npm install js.private --save
Usage
import Private from "js.private";
class People {
constructor( firstname, lastname, gender, city, street ){
$( this ).firstname = firstname;
$( this ).lastname = lastname;
$( this ).address.country = country;
$( this ).address.city = city;
this.gender = gender;
}
get name(){
return $( this ).generateName();
}
get info(){
return this.gender + ", " + $( this ).age;
}
get address(){
return $( this ).address.city + ", " + $( this ).address.street;
}
}
const $ = Private({
firstname: "",
lastname: "",
age: 28,
address: {
country: "",
city: ""
},
generateName: function(){
return $( this ).firstname + " " + $( this ).lastname;
}
});
let ivan = new People( "Ivan", "Ivanow", "man", "Russia", "Moscow" );
ivan.name
ivan.info
ivan.address
let anna = new People( "Anna", "Ananina", "woman", "Germany", "Berlin" );
ivan.name
ivan.info
ivan.address
ivan.lastName
anna.gender
ivan.generateName