How do you create a new object in JavaScript?
A function is used for creating custom object classes, by calling it by using the keyword new. A special variable this is references the new object that is being constructed(current object). This function must not return a value.
The following code snippet depicts the creation of an object of class myclass. function myclass()
{
this.containedValue = 0;
this.othercontainedValue = 0;
this.anothercontainedValue = 0;
}
var myobject = new myclass();
How do you create a new object in JavaScript?
In order to generate dynamic content, JSP provides for creating, modifying and interacting with Java objects. The implicit objects like page, config, request, etc are called so because their availability in the in JSP page is automatic.
Also, along with using constructor functions (e.g. var mything = new myObject();), you can use Object Initializers to create objects in JSP.
Example: var myCar = {color:"white",wheels:4,engine:{cylinders:4,size:2.2}};