Because of the increasing hype about AJAX and the “file-format” JSOPN, another subject in the field of web-developmen gets more and more interesting: Javascript-development.All in all, in my opinion a little change is happening to web-development – we try to realize many things on the client.I appreciate this change because, why should I communicate with the server while sorting a chart when the files are already on the client?Exactly these are the types of assignments that are done by Javascript-Frameworks today. In Microsoft’s ASP.NET AJAX Extensions you will find a client-library as well. But there is a general question: How is it possible to encapsulate files in such a Framework? How is it possible to define own Javascript classes with methods?Defining classes and methods in Javascript – Keyword “prototype”Prototype is not only a keyword in the fields of Javascript Framework for defining methods, also in the world of JS.But step by step now.We create a very simple example: a rectangle. The attributes are width and height and we just want to know the area.Step 1: defining the constructor including memberfunction Rectangle()
{
this.height;
this.width;
}In fact, the constructor is a normal JS function because the keyword “class” doesn’t exist in JS. After that we tell them our two attributes “width” and “height” and as usual in OOP beginning with “this”.Step 2: defining getter/setterRead more: Code-Inside Blog International
{
this.height;
this.width;
}In fact, the constructor is a normal JS function because the keyword “class” doesn’t exist in JS. After that we tell them our two attributes “width” and “height” and as usual in OOP beginning with “this”.Step 2: defining getter/setterRead more: Code-Inside Blog International