How to create object properties in JavaScript?

JavascriptWeb DevelopmentFront End Technology

Object properties can be any of the three primitive data types, or any of the abstract data types, such as another object. Object properties are usually variables used internally in the object's methods, but can also be globally visible variables that are used throughout the page.

The syntax for adding a property to an object is −

objectName.objectProperty = propertyValue;

The following code gets the document title using the "title" property of the “document” object −

var str = document.title;
raja
Published on 03-Feb-2018 15:45:22
Advertisements