?

Log in

Previous Entry | Next Entry

.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.
Copy right www.questpond.com

Buy 600+ Real Time Interview Videos

Call +91-22-66752917 or mail us on questpond@questpond.com for more details on C#, .NET, ASP.NET, SQL Server interview question videos.

SQL Server interview question videos

Latest Month

March 2017
S M T W T F S
   1234
567891011
12131415161718
19202122232425
262728293031 

Tags

Powered by LiveJournal.com