- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is an object in JavaScript and access any property ?**
Accessing Property Of An Object
Without objects there is no JavaScript. Everything such as boolean,numbers,functions etc are all objects.Accessing properties of an object is explained in the following method.
Example-1
<html> <body> <script> myObj = {"name":"Ramesh","age":30,"family": [{"mother":"Geetha","father":"Rao"}],"city":"Berlin"}; var res = myObj.family[0].mother; document.write(res); </script> </body> </html>
Output
Geetha
Example-2
<html> <body> <script> myObj = {"name":"Ramesh","age":30,"family": [{"mother":"Geetha","father":"Rao"}],"city":"Berlin"}; var res = myObj.city; document.write(res); </script> </body> </html>
Output
Berlin
- Related Articles
- How to access an object through another object in JavaScript?
- How to create an object and access its properties in JavaScript?
- What is the 'new' keyword in JavaScript to create an object and how to access values?
- Iterate over an object and remove false property in JavaScript
- How to access an object value using variable key in JavaScript?
- Can we check if a property is in an object with JavaScript?
- What is a NaN property of a Number object in JavaScript?
- What is an Object Oriented Programming in JavaScript?
- Access property as a property using 'get' in JavaScript?
- MongoDB query to access an object in an array
- How to delete a property of an object in JavaScript?
- How to get Property Descriptors of an Object in JavaScript?
- How to add, access JavaScript object methods?
- Setting property in an empty object using for loop in JavaScript.
- How to access cookies using document object in JavaScript?

Advertisements