JavaScript/Reserved words/this

The this keyword
The this keyword allows a method to read and write the property variables of that instance of the object.

The following example uses an initial capital letter for PopMachine to help indicate that the object needs to be created with the new keyword. You can use the new keyword with any function to create an object, but it will be much easier to keep track of what you're doing, if you only use new with functions that are meant just for the purpose, and mark those functions by naming them with an initial capital letter.

Examples

 * Example 1

Please notice that the above method is inefficient and will use way too much memory inside the browser, if you need to create a serious JavaScript class then you must first learn about prototypes.


 * Example 2

The total number of quarters would now be twenty.