Brooks Patton
I have been working in the IT field for most of my professional career, first as a Systems Administrator at NASA Ames Research Center, as a software developer, and now I am an instructor at Galvanize.
Don't let anyone tell you its impossible
After this lecture you should be able to
Its very simple, I promise you
function MyConstructor(){
}
And we can create an instance of the constructor
function MyConstructor(){
}
var myInstance = new MyConstructor();
What is myInstance?
function MyConstructor(){
var hello = 'world';
return hello;
}
var myInstance = new MyConstructor();
What is myInstance?
What can we use to create variables for the instance?
function Car(make){
this.make = make;
}
var prius = new Car('toyota');
console.log(prius);
Add the following properties to your car
The car is great, but we need to be able to start it
function Car(make, model){
this.make = make;
this.model = model;
this.gas = 100;
this.isOn = false;
}
Car.prototype.start = function(){
this.isOn = true;
}
Uh oh, we ran out of gas, add a method to refuel the car.
function Car(make, model){
this.make = make;
this.model = model;
this.gas = 0;
this.isOn = false;
}
Car.prototype.start = function(){
this.isOn = true;
}
Where can you use this?
Its kind of a personal thing
By Brooks Patton
Object oriented javascript is fun and easy!
I have been working in the IT field for most of my professional career, first as a Systems Administrator at NASA Ames Research Center, as a software developer, and now I am an instructor at Galvanize.