Creating a JavaScript Constructor
Yes its time. Now that we created and worked with a few objects its time for us to know how to create our own objects. Constructors in JavaScript are very simple if you know what a function is then you know how to create a constructor. Now that you know its easy to create lets now talk about how to turn functions into constructors. Every function can be a constructor its that simple. Only when we actually trigger the function does javascript actually define it as that. The step involved is by calling the 'new' key. By the end of this session you will know how to create a constructor, you will know how to build objects based on this constructor and define them as a variable.
We start talking about 'this' and what it actually means. The this is not a static value it always returns to us what we are when we are in it. And as such when we call the this operator depending on where we are in our code we will get a different value returned. The nearest object we are in is always returns to us. Although we don't talk about it much at this stage pay a lot of attention to the key word this as it will help you a lot through out the course as we start in later sessions about scope.