Default plugin options
Plugins typically contain default options that will act as the baseline default configuration for the
plugins’ logic. These options are used when the plugin is invoked. In the code below, I am
creating a defaultOptions object containing a single property (startCount) and value (0).
This object is stored on the count function $.fn.count.defaultOptions. We do this so the
options are configurable from outside the plugin.
Sample: sample87.html
Custom plugin options
Typically, the default plugin options can be overwritten with custom options. In the code below, I
pass in a customOptions object as a parameter to the plugin function. This object is combined
with the defaultOptions object to create a single options object. We use the jQuery utility
method extend() to combine multiple objects into a single object. The extend() method
provides the perfect utility for overwriting an object with new properties. With this code in place,
the plugin can now be customized when invoked. In the example, we pass the count plugin a
custom number (500) to be used as the starting point for the count. This custom option
overrides the default option (0).
88