An object is a standalone entity that stores multiple values as properties and methods. JavaScript objects are used to represent real-world entities such as Employee, Student, Product, Customer, etc.
An object is a standalone entity that stores multiple values in the form of properties and methods.
Properties are key-value pairs that store data.
Methods are functions stored inside an object.
Objects can contain other objects as properties.
Create an employee object using curly braces.
Add firstName and lastName properties.
Create getFullName() method to return the employee's full name.
Create an address object inside the employee object.
Use hasOwnProperty() to determine whether mobile exists.
If mobile does not exist, add it dynamically.
Print the object, keys, values and employee details.
Every employee can be represented as an object containing personal information, address, salary, department, and methods such as getFullName() or calculateSalary().
An Object Literal is the simplest way to create an object using curly braces.
Object Literal uses {}, whereas Object Constructor uses new Object(). Object Literal is shorter and more commonly used.
It returns an array containing all property names.
It returns an array containing all property values.
It checks whether a property exists directly on the object.
1. Which is the simplest way to create an object?
2. Which method returns property names?
3. Which method checks whether a property exists?
Create a Student object using Object Literal with name, age, course, marks, address, and getDetails() method.
