Click below for Step by Step and Interview Q & A (dotnetinter) wrote,
Click below for Step by Step and Interview Q & A
dotnetinter

.NET interview questions: - Explain and demonstrate creation of classes in JavaScript and prototype

.NET interview questions: - Explain and demonstrate creation of classes in JavaScript and prototype in JavaScript?

Following are .NET interview questions related to JavaScript: -

Creating classes in JavaScript: -

JavaScript won’t support classes. We have only functions in JavaScript and using them we can bring OOP style programming JavaScript.

Demonstration: -

function Employee()
{
            this.Name=””;
            this.Address=””;
            this.Work=function(){};
}
.
.
.
var e=new Employee();
e.Name=”Sukesh Marla”;
e.Address=”Mumbai”;
e.Work();

Prototype in JavaScript: -

Prototype allows us to add new properties and methods to Object.

Demonstration: -

Employee.prototype.Age=SomeDefaultValue;

var e=new Employee();
e.Name=”Sukesh Marla”;
e.Address=”Mumbai”;
e.Age=55;
e.Work();

Hope you enjoyed reading this and learned something new. Your comments and votes are always welcome.

If you are looking for some hard core live training on MVC, WCF, Design Patterns, BI, WPF, TFS, HTML5 visit www.sukesh-Marla.com or contact SukeshMarla@Gmail.com.
Tags: .net, .net interview questions, creating class in javascript, csharp interview questions, it interview questions with answers, javascript, programming interview questions, prototype in javascript
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments