Javascript Objects

Javascript variables:       var person = “John Doe”;

Javascript objects are variables too. But objects can contain many values.The values are written as name : value pairs.

eg. var person = {firstName:”John”, lastName:”Doe”, age:50, eyeColor:”blue”};

Object properties can be both primitive values, other objects, and functions.

Creating new objects:
1) Using an Object Literal
2) Using the JavaScript Keyword new
3) Using an object constructor

Javascript Properties:

1)  person.age
2)  person[“age”]
3)  x = “age”; person[x]

Delete properties:    delete person.age

Javascript Object Prototypes:

Every JavaScript object has a prototype. The prototype is also an object.
All JavaScript objects inherit their properties and methods from their prototype.

eg. Person.prototype.nationality = “English”;
eg. = function()  {
return this.firstName + ” ” + this.lastName;

Links to reference post :

Javascript basics

1) Javascript classes and object oriented programming basics:,



2) JS functions:

The parameters of a function call are the function’s arguments. Arguments are passed to functions by value.

If the function changes the value of an argument, this change is not reflected globally or in the calling function.

However, object references are values, too, and they are special: if the function changes the referred object’s properties, that change is visible outside the function.


The this keyword does not refer to the currently executing function, so you must refer to Function objects by name, even within the function body.


var multiply = function func_name(x, y) {
   return x * y;

There is a distinction between the function name and the variable the function is assigned to.

The function name cannot be changed, while the variable the function is assigned to can be reassigned.

The function name can be used only within the function’s body.

Attempting to use it outside the function’s body results in an error (or undefined if the function name was previously declared via a var statement).