Description
The prototype
property of the File
object allows you to add methods and properties to the File
object. If you are adding a method, you set the instance equal to the name
of the method you have defined.
Example
Listing 9.113 creates a new property and method of the File
object. An instance is created and the new property is set. The new method is then called to verify the property, and, if it is incorrect (which it is), an error message is written to the page.
<server>// Define the method that we prototyped. function verifyTEXT(){// Check to see if the type property we added is set to a valid value. if(this.type == "text"){ return true; }else{ return false; } } ...
Get Pure JavaScript, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.