Tuesday, August 24, 2021

Basic Introduction to Objects in Javascript

Object in Javascript : In javascript like Array we have another data structure which one called as object. In object we give name for each properties and use curly bracket to hold an object.In array order matter a lot for retrieving value but in Object it does not matter.

// Array in Javascript...

const anilDetails = [
'Anil',
'Singh',
2021 - 1990,
'programmer',
['ram', 'shyam', 'mohan', 'sohan'],
]

// Object define in Javascript ..

const anilDetails = {
firstName: 'Anil',
lastName: 'Singh',
age: 2021 - 1990,
job: 'programmer',
friends: ['ram', 'shyam', 'mohan', 'sohan'],
}
//Accessing the object Properties..

console.log(anilDetails.firstName);

0 comments

Post a Comment