JSFiddle - React, Tailwind, and code Playground
by pmamode
HTML
<div class="members-wrapper"></div>
JavaScript
// define the class
var family = [];
var Person = function() {
this.id = "0";
this.firstName = "firstName";
this.firstNameReference = null;
this.middleName = "middleName";
this.middleNameReference = null;
this.lastName = "lastName";
this.lastNameReference = null;
this.gender = "gender";
this.genderReference = null;
};
Person.prototype.setFirstNameAndReferences = function(firstName,firstNameReference) {
this.firstName = firstName;
this.firstNameReference = firstNameReference;
return this;
};
Person.prototype.save = function() {
family.push(this);
console.log(
"saving " + this.firstName + " : " + this.firstNameReference
);
// save to database here...
return this;
};
Person.prototype.stringify = function() {
console.log(JSON.stringify(family));
return this;
};
new Person()
.setFirstNameAndReferences({"Bob",[ 1,"family search",5])
.save()
.stringify();
new Person()
.setFirstNameAndReferences("Jill",[ 4,"Ancestry",6])
.save()
.stringify();