Objectives and Skills[edit | edit source]
Objectives and skills for this lesson include:
- Complete and debug code that uses objects
- Properties; methods; instantiation; Date object; retrieve date and time parts; localize date format (MM/DD vs DD/MM); add and subtract dates
Readings[edit | edit source]
Multimedia[edit | edit source]
Examples[edit | edit source]
- Example Code
Activities[edit | edit source]
- Create a web page that allows the user to enter book information for a bibliography. Include properties for title, author, year, publisher, city, and state. Respond to one or more user interface events to create an instance of a Book object and then display the book properties in APA format:
Last, F. M. (Year) Title. City, State: Publisher.
- Extend the program above by adding an APA method to your object that automatically formats the book for display. Use the APA method to format output, replacing the display code above.
- Extend the program above by adding an MLA method to your Book object that automatically formats the book for display. Display both APA and MLA formats for the book:
APA: Last, F. M. (Year) Title. City, State: Publisher.
MLA: Last, First M. Title. Publisher, Year.
- Extend the program above, allowing the user to enter multiple book titles, one at a time. Add each book to an array of books. Display the full array in APA and MLA format after each object is added to the array.
- Extend the program above, allowing the user to choose either APA or MLA format, and display the selected format for each book. List the books in alphabetical order.
Lesson Summary[edit | edit source]
- An object is a set of properties or methods. Each object holds related data.
- Objects are written in the name:value pair format. Each pair must be separated by a comma. 
- Object properties may be accessed using the dot notation or the bracket notation. 
Key Terms[edit | edit source]
- An action that an object can perform. A method is a function stored as a property. 
- Refers to the owner of a function.
See Also[edit | edit source]
- Fireship.io: Objects
- MDN: Working with Objects
- TutorialsPoint: What is the difference between a method and a function
References[edit | edit source]
- EasyBib:APA Book Reference
- EasyBib:MLA Book Reference
- MDNː Property accessors