1. What are Objects
Objects are one of the datatype in JavaScript which is very useful as it can store multiple type of values like: string, Boolean, int, etc.
For example:
Properties
book.name= Harry Potter
book.color= Purple
book.size= A4
2. Accessing the data
for example:
const person = {
firstName: "John",
lastName: "Doe",
age: 50,
eyeColor: "blue"
};
console.log(person.age);
console.log(person.eyecolor);
Output:
50
blue
3. Object Methods
Object Methods can be accessed by using functions which are stored as properties in JavaScript.
Example:
const my_object = {
firstName: "Ronn",
lastName : "Doe",
uid : 9980,
}
};
console.log(my_object)
Output:
firstName: "Ronn",
lastName : "Doe",
uid : 9980,
4. Accessing Object Methods
Syntax:
object_name.property;
OR
object_name["property"]
Top comments (0)