Introduction
In my previous article I explained one of the "New Feature of JavaScript in Visual Studio 2012 i.e. Strict Mode". In today's article you will learn about one more new feature of Java Script in Visual Studio 2012, Prototype and Prototype Inheritance.
In JavaScript, prototype is a property of functions and of objects that are created by constructor functions. The prototype of a function is an Object, it's main use is when a function is used as a constructor.
Step 1
First of all add a JavaScript page to your Windows or Web Application. This can be done by right-clicking on your application and then "Add New Item".

Now in the New Item list select the JavaScript Style Sheet.

Step 2
Now in the Style Sheet we will first create a Constructor named "Vehicle Constructor".
function Vehicle(wheels, engine)
{
this.wheels = wheels;
this.engine = engine;
}
Here the prototype of the Vehicle function is the prototype of any object instantiated with the Vehicle constructor.
Step 3
Now we will use the Prototype Property to add properties and methods to the Object.
var testVehicle = new Vehicle(2, false);
Vehicle.prototype.color = "red";
var testColor = testVehicle.color;
Now the value of testcolor is Red
Step 4
You can even add properties and methods to predefined Objects. Like here we will define a Trim method on the String Prototype Object and all the Strings in your script will inherit the method.
String.prototype.trim = function ()

Abhishek BhatPosted Mar 4, 2013, 3:53 AM
You have written a nice article. But, I want to bring to your notice that Prototype was supported previously also in Javascript. This is a not a new feature.