Working with User-Defined Objects
Welcome to the "Working with User-Defined Objects" Practice Lab. In this module, you will be provided with the instructions and devices needed to develop your hands-on skills.
Welcome to the Working with User-Defined Objects Practice Lab. In this module, you will be provided with the instructions and devices needed to develop your hands-on skills.
The following exam objective is covered in this lab:
- 2.3 Complete and debug code that uses objects
It will take approximately 30 minutes to complete this lab.
Exercise 1 - Creating User-Defined Objects
You deal with various kinds of objects in day-to-day situations. For example, your computer is an object. It has its own set of common characteristics such as the type, model number, memory capacity, processor speed, etc. However, the values for these characteristics do not remain the same for all computers. Each computer will have different values for the common characteristics. You can call the common characteristics as properties. The computer can have certain functions of its own such as booting, processing, etc. You can call these functions as methods. To sum up, an object (computer) can have its own set of properties (model number, processor speed) and methods (booting, processing).
Methods are the actions or set of statements that will be executed on the objects. A method will have a name and a set of parameters that are optional. You need to use the “.” (dot) operator along with the object name to access the method. Thus, an object acts as a container to store various properties and methods.
- Using the new keyword: You can use the new keyword to create an object.
- Using the object literal: You can use the object literal to create an object. The properties with their values are listed within the curly braces.
- Using the object constructor function: You can define an object constructor function to create an object. You need to call the object constructor function with the new keyword to create a new object.
In this exercise, you will learn to create user-defined objects, assign properties and methods to the created objects, and access the objects. You will perform the following tasks:
- Task 1 - You will download the Visual Studio Code workspace (ComputeGrade) from the Intranet and create a new HTML page named Grade_Object.html in the ComputeGrade workspace.
After completing this exercise, you will be able to:
IT & Cybersecurity certification hands on practice labs and practice exams for certifications and skill development.
See the full benefits of our immersive learning experience with interactive courses and guided career paths.