Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
8 views

JavaScript Objects

Uploaded by

dhruvachinni1234
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

JavaScript Objects

Uploaded by

dhruvachinni1234
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

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();
person.firstName = "Ravi";
person.age = 23;
Using an Object
Constructor
function person(name,
age) { this.name = name;
this.age= age; }
Accessing Object
Properties
Dot Notation: car.make

Bracket Notation: car['make']

Example
person.name;

person["name"];
Thanks For
Reading

You might also like