In JavaScript, a reference type is a data structure used to organize data and functionality together .
An object is an instance of a particular reference type. How objects are created:
var New Object ();
The example above creates a new instance of the object reference type and then saves the instance in the variable person.
There are two ways to create objects that have constructors and object literals .
1. How to construct a function
Use the new operator followed by the object constructor.
var New = "Rustle of the cold" = 18;
2. Object Literal method
A shorthand for an object definition to simplify the process of creating an object that contains a large number of attributes. Example:
var p = { name:"rustling the Cold", age :+};
In the case of object literal syntax, the property name can also use a string, for example:
var p = { "name": "Rustling the Cold", "age": 5:true}
The example above creates an object that contains the name, age, and 53 properties. The numeric property names here are automatically converted to strings.
In addition, when you use object literal syntax, you can define an object that contains default properties and methods if you leave the curly braces blank. For example:
var p == "Rustle of the cold" = 18;
In general, the properties of Access objects use dot notation, and in JavaScript you can also use square brackets to access the properties of an object. When you use square brackets syntax, you should place the property you want to access in square brackets as a string, for example:
Alert (p["name"]); alert (p.name);
There is no difference between these two ways of accessing functionality. The advantage of square brackets syntax is that you can access properties by using variables:
var propname = "name"// "rustling the Cold"
You can also use square bracket notation if the property name contains characters such as keywords or reserved words that can cause errors. For example:
p["First Name"] = "rustling the cold";
The property first name contains a space that cannot be accessed by dot notation.
Javascript:object type