GROUP: Vishwa Bhagvat , Alejandro Jimenez , Duy Ngo
2a. Constructor functions are used to create objects and set specified properties or initial values for that object.
Function plane(new_model, new_make, new_year)
{
this.model = new_model;
this.make = new_make;
this.year = new_year;
}
var my_plane = new plane("Plane", "V123", "2000");
2b. You can add a method to a Javascript object by initializing a property in the constructor that points to the method.
function display()
{
Document.write(this.model, “<br/>”
this.make, “<br/>”
this.year, “<br/>”);
}
function plane(new_model, new_make, new_year)
{
this.model = new_model;
this.make = new_make;
this.year = new_year;
this.display = display;
}
OR
plane.prototype.display = display;
2c. The prototype property can be used to create one pointer compared to a separate pointer for the property everytime a new object is created. Every new object will use the same pointer referenced by the prototype.
plane.prototype.display = display;
(
Edited: 2016-05-16)
GROUP: '''Vishwa Bhagvat , Alejandro Jimenez , Duy Ngo'''
2a. Constructor functions are used to create objects and set specified properties or initial values for that object.
Function plane(new_model, new_make, new_year)
{
this.model = new_model;
this.make = new_make;
this.year = new_year;
}
var my_plane = new plane("Plane", "V123", "2000");
2b. You can add a method to a Javascript object by initializing a property in the constructor that points to the method.
function display()
{
Document.write(this.model, “<br/>”
this.make, “<br/>”
this.year, “<br/>”);
}
function plane(new_model, new_make, new_year)
{
this.model = new_model;
this.make = new_make;
this.year = new_year;
this.display = display;
}
OR
plane.prototype.display = display;
2c. The prototype property can be used to create one pointer compared to a separate pointer for the property everytime a new object is created. Every new object will use the same pointer referenced by the prototype.
plane.prototype.display = display;