Objects in JavaScript, just as in many other programming languages, can be compared to objects in real life.In JavaScript, an object is a standalone entity, with properties and type.

A JavaScript object has properties associated with it. A property of an object can be explained as a variable that is attached to the object. Object properties are basically the same as ordinary JavaScript variables, except for the attachment to objects. The properties of an object define the characteristics of the object.

Like all JavaScript variables, both the object name (which could be a normal variable) and property name are case sensitive. You can define a property by assigning it a value.

var myCar = new Object();

myCar.make = “Ford”;

myCar.model = “Mustang”; myCar.year = 1969;

myCar.noProperty; // Unassigned properties of an object are undefined

Properties of JavaScript objects can also be accessed or set using a bracket notation

myCar[“make”] = “Ford”;

myCar[“model”] = “Mustang”;

myCar[“year”] = 1969;

An object property name can be any valid JavaScript string, or anything that can be converted to a string, including the empty string. However, any property name that is not a valid JavaScript identifier (for example, a property name that has a space or a hyphen, or that starts with a number) can only be accessed using the square bracket notation. This notation is also very useful when property names are to be dynamically determined (when the property name is not determined until runtime). Examples are as follows:

// four variables are created and assigned in a single go, // separated by commas

var myObj = new Object(), str = “myString”, rand = Math.random(), obj = new Object();

myObj.type = “Dot syntax”;

myObj[“date created”] = “String with space”;

myObj[str] = “String value”;

myObj[rand] = “Random Number”;

myObj[obj] = “Object”;

myObj[“”] = “Even an empty string”;

You can use the bracket notation with for…in to iterate over all the enumerable properties of an object.

for (var i in myCar) {

if (obj.hasOwnProperty(i)) {

result += i + ” = ” + obj[i] + “\n”;

}

}

Creating new objects

Using object initializers
You can create an object using an object initializer.The syntax for an object using an object initializer is:

var myCar = { make: “Ford”, year :2016 }

You can access the value of object using dot notation. Eg:

myCar.make;

myCar[“make”];

Using a constructor function
To define an object type, create a function for the object type that specifies its name, properties, and methods. Eg:

function Car(make, model, year) {

this.make = make;

this.model = model;

this.year = year;

}

var mycar = new Car(“Eagle”, “Talon TSi”, 1993); // creating new object

mycar.make

mycar.year

Note that you can always add a property to a previously defined object. For example, the statement

car1.year = “2014”;

Using the Object.create method

Objects can also be created using the Object.create() method. This method can be very useful, because it allows you to choose the prototype object for the object you want to create, without having to define a constructor function.

// Car properties and method encapsulation

var Car = {

make: “Ford”, // Default value of properties

displayMake : function(){ // Method which will display model of Car

console.log(this.make);

}

}

// Create new animal type called animal1

var myCar = Object.create(Car);

myCar.displayMake(); // Output:Ford

// Create new car model called Suzuki

var newCar = Object.create(Car);

newCar.model = “Suzuki”;

newCar.displayModel(); // Output:Suzuki

For read more about you can refer here : Working with objects