Creating A Prototype
The standard way to create a new prototype in JavaScript is by using the object constructor function as displayed below:
| Input | Output |
|---|---|
function student(first, last, school, age){
this.firstName = first;
this.lastName = last;
this.school = school;
this.age = age;
}
var student1 = new student("Jane", "Doe", "DBC", 24)
|
>> console.log(student1)
=> { firstName: 'Jane',
lastName: 'Doe',
school: 'DBC',
age: 24 }
|