JavaScript
Objects
What is an object?
Objects are collections of key-value
pairs. They allow you to group
related data and functions, making
your code more organized and
easier to manage.
Think of objects as real-world entities
like a car or a person, with properties
and behaviors.
Creating Objects in
JavaScript:
Using an Object Literal
Using the new Keyword
Using an Object Constructor
Using an Object
Literal
An object literal is a list of
name:value pairs inside curly braces
{}.
let person { name: 'Ravi',
age: '23' }
Using the new
Keyword
const person = new
Object();
[Link] = "Ravi";
[Link] = 23;
Using an Object
Constructor
function person(name,
age) { [Link] = name;
[Link]= age; }
Accessing Object
Properties
Dot Notation: [Link]
Bracket Notation: car['make']
Example
[Link];
person["name"];
Thanks For
Reading