/* A constructor in Javascript is used to create a new object and set values
for any existing object properties*/
class Animal{
constructor (name, height, weight){
console.log("created animal named", name)
}
nameLength() {
return name.length;
}
}
var dog = new Animal("Fido", 25, 90);
var fish = new Animal("Goldie", 2, .02);
console.log(dog.nameLength);
//Constructor Function
function BellBoy (name, age, hasWorkPermit, languages) {
this.name = name;
this.age = age;
this.hasWorkPermit = hasWorkPermit;
this.languages = languages;
}
//Create New Object From Constructor Using Arguments
var Earl = new BellBoy('Earl E.Bird', 23, true, ['French', 'German'])
//Access the Properties and Their Values
console.log('Name : ', Earl.name)
console.log('Age : ', Earl.age)
console.log('Verified Work Permit : ', Earl.hasWorkPermit)
console.log('Languages : ', Earl.languages)
var MyConstructor = function(p1, p2, p3){
this.p1 = p1;
this.p2 = p2;
this.p3 = p3;
};
const o = {};
o.constructor === Object;