The data contained in the object can be accessed in two ways
Both property and method
Attributes are variables belonging to a specific object, and methods are functions that can only be deployed by a specific object.
An object is a data entity that is composed of some related properties and methods. In JavaScript, properties and methods are accessed using "dot" syntax.
Suppose a car has brand, band, and color attributes. You can access these attributes through the following methods
Assume that Car is associated with some functions such as move(), stop(), and addOil. These functions are the methods of the Car object. You can use the following methods to dispatch it
These properties and methods are gathered together to form the Car object. In other words, the Car object can be regarded as the collective name of all these properties and methods.
In order for the Car object to describe a specific car, you need to create an instance of the Car object. The instance is the specific representation of the object. Objects are collective names and instances are individuals.
For example, BMW and Xiali are all cars, and they can all be described as Car. A BMW and a Xiali are both different sizes. They are both Car objects, but different instances.
In JavaScript, create a new instance using the new keyword. As follows
var myCar = new Car();
The above code creates a new instance of the Car object myCar. With this instance, you can use the properties and methods of the Car object to retrieve the properties and methods of myCar. The code is as follows
In JavaScript, strings and arrays are objects. Strictly speaking, everything is an object
Use Date object to test the execution speed of the computer