Accessing Properties in JavaScript

Accessing Properties

A property of an object is some piece of named data it contains. These are accessed with dot
operator applied to an object alternative to the dot operator is the array [ ] operator.

Syntax: – object_name.property_name

Ex:-

Accessing Properties

Accessing Methods

Object members that are functions are called methods. These are accessed with dot operator applied
to an object alternative to the dot, the operator is the array [ ] operator.

Syntax: – object_name.Method_name( );

Ex:-

Adding Properties/Methods

Syntax:-
Object_name.Property_name = value;
Object_name[„Property_name‟] = value;

Deleting Properties

Delete operator is used to delete instance properties.

Syntax:- delete object_name.property_name
Ex: – delete fees.Rahul

After removal with delete operator, the property has the undefined value.

Tagged : / / / /

Leave a Reply