In this conclusion to a three-part series on nesting JavaScript functions, we see how nested functions can be used as object types. We shall make it simple. We shall consider only the case where there is only one level of nested functions.
The first function, functionType1(), will become the method of the object type. The second function, objectFunction(), will be added as a method to the object (instance).
The next function of the code is actually the constructor function. This constructor function creates the object type. The name of the object type is ObjectType. The object type has a property and one method. The method is the first function in the code.
Next, you have the statement that creates the object (instance). The name of the object is theObject. This object inherits all the properties and methods of the object type. Next you have a statement that adds a method to the object (instance).
You have two HTML buttons in the code. The first one calls the object type method, using the object. This method displays the string "This is function type one." The second one calls the object method. This method displays the string "This is object function."