An object is a special kind of data, with a collection of properties and methods.
Let us discuss an example to have a clear idea:
A person is an object. Properties are the values associated with the object. The persons' properties include name, height, weight, age, skin tone, eye color, etc. All persons have these properties, but the values of those properties will differ from person to person.
Objects also have methods. Methods are the actions that can be performed on objects. The persons' methods could be eat(), sleep(), work(), play(), etc.
The syntax for accessing a property of an object is:
You can call a method with the following syntax:
Asked In: Many Interviews |