// We "literally" write the object that we want,
// declaring the object's properties and their values.
//Create a person with first and last names
//and behavior (function) to combine them into a full name.
var person = {
firstName: "Kweku",
lastName: "White",
fullName: function() {
return this.firstName + " " + this.lastName;
}
}
person.firstName;
// => "Kweku"
person.fullName();
// => "Kweku White"
var personShared = {
greet: function () { etc. }
sleep: function () { etc. }
}
//creating an admin as a person
var adminShared = Object.create(personShared)
adminShared.delete = function () {
//function here
}
//creating a person who is a person but has extra functionality of admin shared - "delete"
var alyssa=Object.create(adminShared)
alyssa.name = "Alyssa Diaz"
//She then has access to personShared through protoype chaining
alyssa.greet()
var Person = function(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
//creating a function that belongs to all instances (aka Class Function)
Person.prototype.fullName = function() {
return this.firstName + " " + this.lastName
}
var grayson = new Person("Grayson", "Arthur");
grayson.firstName;
// => "Grayson"
var warner = new Person("Warner", "Constable");
warner.fullName();
// => "Warner Constable"