Using vehicles as an example, if a vehicle is an object and color and speed are its properties then we can add properties to add an object by using the "this" keyword followed by the dot (.) operator.
Now let's extend the object function, myobject, to contain two properties, each containing a string of text.
Syntax
The properties defined in the code above can be accessed by the given code:
Now let's work with a String Object
We have learned from the preceding about String objects and various properties. There are some important properties like length and prototype. The length property specifies the number of characters in a string, while the prototype adds properties and methods to an object. Let's do some exercises.
See the given code
In the code above a function named employee is created with the three parameters name, jobtitle, and salary. Two objects emp1 and epm2 of the employee type are created using the "new" keyword and values are passed for the specified parameters. The emp2 object has an additional property, named doj, by using the prototype property.
See the output for the following code:
So this was a simple example of a String object. Do more exercises and be connected with your questions.