?

Log in

No account? Create an account

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

Tags

Latest Month

September 2017
S M T W T F S
     12
3456789
10111213141516
17181920212223
24252627282930
Powered by LiveJournal.com