Javascript – Objects

In Javascript, objects are arrays where indexes are the property names. You can declare an object:

var person = {};

The properties are separated with ‘,’ and the key/value for its property is separated with ‘:’. The property name can have single quotes, double quotes or nothing.

"name": "Kronos"

You can access a property using ‘.’. If the property name starts with a number or is a reserved word then you have to use ‘[]’ and quotes: = "Kronos";
person['1name'] = "Kronos";

An object can contain another object and functions/methods:

, <span>Javascript – Objects</span>, KandZ
, <span>Javascript – Objects</span>, KandZ

this keyword is used to access the object’s properties or call the object’s methods.

In Javascript, you can add or delete properties and methods after an object’s creation.

, <span>Javascript – Objects</span>, KandZ
, <span>Javascript – Objects</span>, KandZ

104980cookie-checkJavascript – ObjectsJavascript – Objects

Related posts

2 Thoughts to “Javascript – Objects

Comments are closed.