<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>JScript Blog : Object Orientation in JScript</title><link>http://blogs.msdn.com/jscript/archive/tags/Object+Orientation+in+JScript/default.aspx</link><description>Tags: Object Orientation in JScript</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Classes in JScript – Part III: Class Hierarchy and Data Encapsulation</title><link>http://blogs.msdn.com/jscript/archive/2007/10/31/classes-in-jscript-part-iii-class-hierarchy-and-data-encapsulation.aspx</link><pubDate>Wed, 31 Oct 2007 10:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5794780</guid><dc:creator>don.raman</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/jscript/comments/5794780.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jscript/commentrss.aspx?PostID=5794780</wfw:commentRss><wfw:comment>http://blogs.msdn.com/jscript/rsscomments.aspx?PostID=5794780</wfw:comment><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt; TEXT-ALIGN: justify"&gt;&lt;FONT face=Calibri size=3&gt;In this post I will be discussing how one can achieve &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class Hierarchy&lt;/SPAN&gt; and &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Data Encapsulation&lt;/SPAN&gt; in &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;JScript&lt;/SPAN&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;I will take the same example that was used for the &lt;A class="" title="Classes in JScript Part 1" href="http://blogs.msdn.com/jscript/archive/2007/09/24/classes-in-jscript-part-i.aspx" target=_blank mce_href="http://blogs.msdn.com/jscript/archive/2007/09/24/classes-in-jscript-part-i.aspx"&gt;first&lt;/A&gt; and &lt;A class="" title="Classes in JScript Part 3" href="http://blogs.msdn.com/jscript/archive/2007/09/30/classes-in-jscript-part-ii-instance-properties-methods-class-properties-methods.aspx" target=_blank mce_href="http://blogs.msdn.com/jscript/archive/2007/09/30/classes-in-jscript-part-ii-instance-properties-methods-class-properties-methods.aspx"&gt;second&lt;/A&gt; parts and will keep updating it as and when required.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;function Rectangle (ht, wt) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;this.height = ht;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;this.width=wt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Rectangle.prototype.area = function() {return this.height * this.width;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;var rect1 = new Rectangle(5,10);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;var rect2 = new Rectangle(2,4);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;var rect1Area = rect1.area(); // rect1.area() will return 50.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;var rect2Area = rect2.area(); // rect2.area() will return 8.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Languages that support class based inheritance define two distinct entities: &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Classes&lt;/SPAN&gt; and &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Instances&lt;/SPAN&gt;. We defined &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class&lt;/SPAN&gt; in first part as the structure of an object. It defines exactly what fields an object contains, their types and methods to operate upon the object. A &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class&lt;/SPAN&gt; is an abstract thing. There can be several &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;instances&lt;/SPAN&gt; of a single &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class&lt;/SPAN&gt;. Each &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Instance&lt;/SPAN&gt; has its own state.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri size=3&gt;However languages (e.g. JScript) that support prototype based inheritance do not make distinction between Class and Instances. These languages just have objects. &lt;/FONT&gt;&lt;A class="" title=1044714 name=1044714&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt;A prototype-based language has the notion of a &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2; mso-bidi-font-weight: bold"&gt;prototype object&lt;/SPAN&gt;, which means that an object is used as a template from which one can get the initial properties for a new object.&lt;/FONT&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; Also any object can be specified as a prototype for another object.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;In &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class&lt;/SPAN&gt; based languages, a hierarchy of classes can be created through &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class&lt;/SPAN&gt; definitions. In the definition of a &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class&lt;/SPAN&gt;, we can specify that it is a derived class of an existing &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class&lt;/SPAN&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;As described in part I, JScript does not support the keyword &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class&lt;/SPAN&gt;. It simulates &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Classes&lt;/SPAN&gt; using &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Constructor&lt;/SPAN&gt; and &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Prototype Objects&lt;/SPAN&gt;. Hence implementing hierarchy of classes is achieved by using &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Constructor&lt;/SPAN&gt; and &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Prototype Objects&lt;/SPAN&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;Let’s extend the above example – &lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;Rectangle&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt; to take co-ordinates. Ideally we would want to have all 8 co-ordinates topLeftX, topLeftY, topRight(X &amp;amp; Y),bottomLeft(X &amp;amp; Y) and bottomRight(X &amp;amp; Y), but for simplicity we will consider only the first two.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Earlier in this post I mentioned that “&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;Also any object can be specified as a prototype for another object.” We&amp;nbsp;use this to achieve inheritance by specifying super class object as a prototype for the child class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;Define the class &lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;PositionedRectangle&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;function PositionedRectangle (topLeftX,topLeftY,height,width) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;this.topLeftX = topLeftX;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;this.topLeftY = topLeftY;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;Assign a new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;Rectangle&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt; object as the prototype for &lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;PositionedRectangle&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt; class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;PositionedRectangle.prototype = new Rectangle;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT face=Calibri size=3&gt;Create an object for the above type:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;var prObj = new PositionedRectangle(2,3,4,5); &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT face=Calibri size=3&gt;When &lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;prObj&lt;/SPAN&gt; is created, it inherits the &lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;height&lt;/SPAN&gt; and &lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;width&lt;/SPAN&gt; properties from the &lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;Rectangle&lt;/SPAN&gt; object due to the prototype set above.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT face=Calibri size=3&gt;On executing the below statement we can see the values assigned to topLeftX, topLeftY, height and width members.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;alert(prObj.topLeftX+" "+ prObj.topLeftY+" "+ prObj.height+" "+ prObj.width);&lt;/SPAN&gt;&lt;/I&gt; //&amp;nbsp;displays 2 3 undefined undefined&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT face=Calibri size=3&gt;Since the height and width properties of Rectangle do not get set, we see “undefined” in the output for them. This is a limitation of the above method. If we had a constructor function for Rectangle which would set default values for height and width properties, say&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;function Rectangle () {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;this.height = 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;this.width=1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT face=Calibri size=3&gt;The output would be 2 3 1 1. It still wouldn’t take the values passed by us.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT face=Calibri size=3&gt;To overcome this, some code needs to be added to the constructor function for &lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;PositionedRectangle&lt;/SPAN&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;function PositionedRectangle (topLeftX,topLeftY,height,width) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;this.topLeftX = topLeftX;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;this.topLeftY = topLeftY;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;//One option would be:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;this.height = height;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;this.width=width;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;//Or second option would be calling the constructor for Rectangle itself&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Rectangle(height,width);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;PositionedRectangle.prototype = new Rectangle;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;var prObj = new PositionedRectangle(2,3,4,5); &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;alert(prObj.topLeftX+" "+ prObj.topLeftY+" "+ prObj.height+" "+ prObj.width);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT face=Calibri size=3&gt;The output now would be 2 3 4 5. Here we just invoke the super class constructor as a method of the child class with the correct set of arguments.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT face=Calibri size=3&gt;So how does this work?&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;First, the &lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;new&lt;/SPAN&gt; operator creates a generic object and sets its prototype property to &lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;PositionedRectangle.prototype&lt;/SPAN&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;The &lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;new&lt;/SPAN&gt; operator then passes the new object to the &lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;PositionedRectangle&lt;/SPAN&gt; constructor as the value of the &lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;this&lt;/SPAN&gt; keyword.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;3.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Next it initializes &lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;topLeftX&lt;/SPAN&gt; and &lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;topLeftY&lt;/SPAN&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;4.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Since Rectangle was called within the scope of the newly created object, its properties (&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;height&lt;/SPAN&gt; and &lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;width&lt;/SPAN&gt;) are correctly set.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;5.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;On returning from the &lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;PositionedRectangle&lt;/SPAN&gt; constructor, JScript assigns the new object to &lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;prObj&lt;/SPAN&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT face=Calibri size=3&gt;If we want to further create a subclass for &lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;PositionedRectangle&lt;/SPAN&gt; class, then we need to set &lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;PositionedRectangle&lt;/SPAN&gt; object as a prototype for the derived class and invoke &lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;PositionedRectangle’s&lt;/SPAN&gt; constructor from the subclass constructor as a method of the subclass.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT face=Calibri size=3&gt;Data Encapsulation:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT face=Calibri size=3&gt;Data encapsulation means that an object's data members should remain private to the object and manipulated through publicly exposed methods. Simply saying programs should not have the ability to modify the properties of objects directly.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT face=Calibri size=3&gt;By default the members of an object are public. No methods are required to access or modify these members.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;In the above code,&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;rect1.height = 10; // will change the height from its old value to 10&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;How can we make the members private?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;The answer is nested functions and not using &lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt; keyword for members. Lets add a member &lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;colour&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt; to the &lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;Rectangle&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt; class. We want &lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;colour&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt; to be private and be modified using publicly exposed methods.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;function Rectangle (ht, wt) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;this.height = ht;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;this.width=wt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;var colour = null;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;// colour now is a private member of this class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;this.setColour = setColour;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;this.getColour=getColour;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;//These methods will be used to access / modify colour.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;function setColour (passedColour) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;colour =passedColour;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;function getColour() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;return colour;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;}&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;var rect1 = new Rectangle(5,10);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify; tab-stops: center 3.25in"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;rect1.setColour (“blue”); &lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;// this will set colour to &lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;blue.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;alert(rect1.getColour); &lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;// this will display &lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;blue&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt; as output.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify; tab-stops: center 3.25in"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;alert(rect1.colour) &lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;// this would display &lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;undefined.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify; tab-stops: center 3.25in"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;Rect1.colour =”red”;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt; /*this will not throw any error but wouldn’t update colour member too. It will create an expando with name colour on the object.*/&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;alert(rect1.getColour); &lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;// this will still display &lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;blue&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt; as output.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify; tab-stops: center 3.25in"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;alert(rect1.colour) &lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;// this would display&lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;red.&lt;/SPAN&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify; tab-stops: center 3.25in"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify; tab-stops: center 3.25in"&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;In this way we can define a private member and methods that manipulate it. Thus we can achieve Data Encapsulation in Jscript.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify; tab-stops: center 3.25in"&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify; tab-stops: center 3.25in"&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;This is not everything that is there to talk about on Classes in Jscript, but this is good enough to get one started. Hope this post was helpful and fun to read!!&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify; tab-stops: center 3.25in"&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify; tab-stops: center 3.25in"&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;This completes the three parts that&amp;nbsp;I had planned to write on this topic. Some more references to understand these concepts:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://www.webdevelopersjournal.com/articles/jsintro3/js_begin3.html" target=_blank&gt;&lt;FONT face="Times New Roman" size=3&gt;http://www.webdevelopersjournal.com/articles/jsintro3/js_begin3.html&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://dean.edwards.name/weblog/2006/03/base/" target=_blank&gt;&lt;FONT face="Times New Roman" size=3&gt;http://dean.edwards.name/weblog/2006/03/base/&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://www.crockford.com/javascript/inheritance.html" target=_blank&gt;&lt;FONT face="Times New Roman" size=3&gt;http://www.crockford.com/javascript/inheritance.html&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://dean.edwards.name/weblog/2006/03/base/" target=_blank&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://devedge-temp.mozilla.org/viewsource/2001/oop-javascript/" target=_blank&gt;&lt;FONT face="Times New Roman" size=3&gt;http://devedge-temp.mozilla.org/viewsource/2001/oop-javascript/&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Thanks,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Ritesh&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;SDET, JScript&amp;nbsp;Team.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5794780" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jscript/archive/tags/JScript+Tutorial/default.aspx">JScript Tutorial</category><category domain="http://blogs.msdn.com/jscript/archive/tags/Object+Orientation+in+JScript/default.aspx">Object Orientation in JScript</category></item><item><title>Classes in JScript – Part II: Instance Properties / Methods &amp; Class Properties / Methods</title><link>http://blogs.msdn.com/jscript/archive/2007/09/30/classes-in-jscript-part-ii-instance-properties-methods-class-properties-methods.aspx</link><pubDate>Sun, 30 Sep 2007 18:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5211537</guid><dc:creator>don.raman</dc:creator><slash:comments>13</slash:comments><comments>http://blogs.msdn.com/jscript/comments/5211537.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jscript/commentrss.aspx?PostID=5211537</wfw:commentRss><wfw:comment>http://blogs.msdn.com/jscript/rsscomments.aspx?PostID=5211537</wfw:comment><description>&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;In this post I will discuss more about the &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Instance Properties&lt;/SPAN&gt; &amp;amp; &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Instance Methods&lt;/SPAN&gt; and &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class Properties &lt;/SPAN&gt;and &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class Methods&lt;/SPAN&gt;.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri size=3&gt;I will take the same example that was used for the &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri color=#800080 size=3&gt;first part&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; and will keep updating it as and when required.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;function Rectangle (ht, wt) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;this.height = ht;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;this.width=wt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Rectangle.prototype.area = function() {return this.height * this.width;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;var rect1 = new Rectangle(5,10);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;var rect2 = new Rectangle(2,4);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;var rect1Area = rect1.area(); // rect1.area() will return 50.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;var rect2Area = rect2.area(); // rect2.area() will return 8.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The above sample code defines a constructor function &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;Rectangle&lt;/SPAN&gt;&lt;/I&gt;. Rectangle has 2 properties &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;height&lt;/SPAN&gt;&lt;/I&gt; and &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;width&lt;/SPAN&gt;&lt;/I&gt;. It also has one method &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;area&lt;/SPAN&gt;&lt;/I&gt; added to its prototype.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;In the above example every instance of Rectangle will have its own copy of &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;width&lt;/SPAN&gt;&lt;/I&gt; and &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;height&lt;/SPAN&gt;&lt;/I&gt; properties. These properties are accessed through the individual instances created. For e.g.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-bidi-font-family: 'Times New Roman'; mso-themecolor: accent1"&gt;height&lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt; property of &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;rect1&lt;/SPAN&gt;&lt;/I&gt; can be accessed and assigned to &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;height&lt;/SPAN&gt;&lt;/I&gt; of &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;rect2&lt;/SPAN&gt;&lt;/I&gt; as&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-bidi-font-family: 'Times New Roman'; mso-themecolor: accent1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;rect2.height = rect1.height; &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The above line of code shows that these properties can be read from or written to using the individual instances with which they are associated.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Such properties are known as &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Instance Properties&lt;/SPAN&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;So what about &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;area&lt;/SPAN&gt;&lt;/I&gt; method? This too is accessed using an instance of &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;Rectangle&lt;/SPAN&gt;&lt;/I&gt;. This would classify as an &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Instance Method&lt;/SPAN&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;An &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Instance Method&lt;/SPAN&gt; is&lt;B style="mso-bidi-font-weight: normal"&gt; &lt;/B&gt;similar to&lt;B style="mso-bidi-font-weight: normal"&gt; &lt;/B&gt;&lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Instance Property&lt;/SPAN&gt; except for couple of differences. One of them is that it is a method rather than a data value. The other is that each instance does not have its own copy of &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Instance Method&lt;/SPAN&gt;. The implementation of such a method uses &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;this&lt;/SPAN&gt;&lt;/I&gt; keyword to refer to the object or instance on which it was invoked.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Both &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Instance Property&lt;/SPAN&gt; and &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Instance Method&lt;/SPAN&gt; can be accessed through an object instance only.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;What happens when I add the following statement to the above example?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;rect1.area =&lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt; &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;function() {return ½ * this.height * this.width;}&lt;/SPAN&gt;&lt;/I&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;How does this affect rect1? Would this affect all other instances of &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd; mso-themecolor: accent1"&gt;Rectangle&lt;/SPAN&gt;&lt;/I&gt;? &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;To answer these questions, it is necessary to understand the fundamental difference in the way Jscript treats reading and writing of properties.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;When we try to read a property (e.g. &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;area&lt;/SPAN&gt;&lt;/I&gt;) of an object (e.g. &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;rect1&lt;/SPAN&gt;&lt;/I&gt;), JScript interpreter first checks if the property queried for is defined by &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;rect1&lt;/SPAN&gt;&lt;/I&gt; object. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;If it is not defined by &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;rect1&lt;/SPAN&gt;&lt;/I&gt;, then JScript interpreter checks whether the property is defined by &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;rect1’s&lt;/SPAN&gt;&lt;/I&gt; constructor’s prototype object.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;If it is not defined by the constructor’s prototype then the interpreter can follow the prototype chain all the way up to &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Object&lt;/SPAN&gt; object if necessary.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;When we try to write (add) a property (as in the above e.g. &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;area&lt;/SPAN&gt;&lt;/I&gt; to &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;rect1&lt;/SPAN&gt;&lt;/I&gt;), JScript creates a new property (&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;area&lt;/SPAN&gt;&lt;/I&gt;) for that particular object (&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;rect1&lt;/SPAN&gt;&lt;/I&gt;) if no property with the same name is already created on it. So &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;rect1&lt;/SPAN&gt;&lt;/I&gt; now has its own property &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;area&lt;/SPAN&gt;&lt;/I&gt;. JScript does not look up the prototype object when adding a property.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Going by the above explanation for reading a property, whenever &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;rect1.area()&lt;/SPAN&gt;&lt;/I&gt; is called, always the newly defined property (one on &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;rect1&lt;/SPAN&gt;&lt;/I&gt;) would be invoked and not the one defined on the prototype object.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;However when we call &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;rect2.area()&lt;/SPAN&gt;&lt;/I&gt;, since &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;area&lt;/SPAN&gt;&lt;/I&gt; property is not defined by &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;rect2&lt;/SPAN&gt;&lt;/I&gt;, it will still call the one defined by its constructor’s prototype object.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Summarizing the above – A new property defined on an object overrides the property having same name defined on its prototype object but it does so only for itself. (&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;rect1.area&lt;/SPAN&gt;&lt;/I&gt; overrides &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;Rectangle.prototype.area &lt;/SPAN&gt;&lt;/I&gt;only for rect1.) No other instances of Rectangle get affected.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;In the above e.g. I want to classify a rectangle as SMALL or BIG depending on its area. Any rectangle which has area less than 10, would be of type SMALL else BIG. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;So I define a property:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Rectangle.MINBIGSIZE = 10;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;MINBIGSIZE&lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt; is a property created on the function constructor (&lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class&lt;/SPAN&gt;) &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;Rectangle &lt;/SPAN&gt;&lt;/I&gt;and not on its instances or prototype object. This is an example of &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class Property&lt;/SPAN&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="COLOR: #c0504d; mso-bidi-font-family: 'Times New Roman'; mso-themecolor: accent2"&gt;Class Property&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt; is a property that is associated with the &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class&lt;/SPAN&gt; itself and not the instance of the &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class&lt;/SPAN&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Irrespective of the number of instances created, there will always be one copy of the &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class Property&lt;/SPAN&gt;. This property is accessed through the class itself.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;In order to figure out whether the rectangle is SMALL or BIG, I define a method &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;type&lt;/SPAN&gt;&lt;/I&gt; which will determine it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Rectangle.type = function (obj) { &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;var retType;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;obj.area()&amp;lt;Rectangle.MINBIGSIZE ? retType="SMALL" : retType="BIG";&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;return retype;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Just as &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;MINBIGSIZE&lt;/SPAN&gt;&lt;/I&gt;,&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt; type &lt;/SPAN&gt;&lt;/I&gt;is created on the constructor function &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0"&gt;Rectangle&lt;/SPAN&gt;&lt;/I&gt;. This is an example of &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class Method&lt;/SPAN&gt;. A &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class Method&lt;/SPAN&gt; is nothing but a function defined as a property of the Constructor. A &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class Method&lt;/SPAN&gt; is a method associated with the &lt;SPAN style="COLOR: #c0504d; mso-themecolor: accent2"&gt;Class&lt;/SPAN&gt; itself and not with an instance.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The above defined method can be called as shown below:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #0070c0; mso-bidi-font-family: 'Times New Roman'"&gt;Rectangle.type(rect1);&lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt; // would return BIG.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;This completes the overview on Instance &amp;amp; Class properties / methods. In the next post, I will discuss data encapsulation and inheritance.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Hope this post was helpful and you enjoyed reading it!!&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Thanks,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Ritesh&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;SDET, JScript&amp;nbsp;Team.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5211537" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jscript/archive/tags/JScript+Tutorial/default.aspx">JScript Tutorial</category><category domain="http://blogs.msdn.com/jscript/archive/tags/Object+Orientation+in+JScript/default.aspx">Object Orientation in JScript</category></item><item><title>Classes in Jscript - Part I</title><link>http://blogs.msdn.com/jscript/archive/2007/09/24/classes-in-jscript-part-i.aspx</link><pubDate>Mon, 24 Sep 2007 11:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5091755</guid><dc:creator>don.raman</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/jscript/comments/5091755.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jscript/commentrss.aspx?PostID=5091755</wfw:commentRss><wfw:comment>http://blogs.msdn.com/jscript/rsscomments.aspx?PostID=5091755</wfw:comment><description>&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Times New Roman'"&gt;I am Ritesh Parikh and have recently moved to Jscript team as a SDET. While starting on Jscript I had a lot of questions. One of them was - Is JScript object oriented? &lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;For a language to be object oriented, it has to provide support for the following:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo2"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;·&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;A mechanism for grouping related functionality into logical “modules” which encapsulate implementation details – i.e. mechanism to define a &lt;SPAN style="COLOR: #c0504d"&gt;Class&lt;/SPAN&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo2"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;·&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;A mechanism for re-using functionality, usually via some kind of inheritance&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo2"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;·&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;A mechanism for treating different implementations as logically “the same kind of thing” – usually polymorphism is implemented via interface implementation and class inheritance&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;Jscript supports all of the above. In this blog&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I will describe how Jscript supports defining &lt;SPAN style="COLOR: #c0504d"&gt;Classes&lt;/SPAN&gt;.&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Times New Roman'"&gt;JScript does not have a formal notion of a &lt;SPAN style="COLOR: #c0504d"&gt;Class&lt;/SPAN&gt;. As a result it is quite different from classic object-oriented languages like C++ or Java. Jscript does not support &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #c0504d"&gt;&lt;A class="" title="Class based inheritance" href="http://en.wikipedia.org/wiki/Class-based_programming" target=_blank mce_href="http://en.wikipedia.org/wiki/Class-based_programming"&gt;Class based inheritance&lt;/A&gt;&lt;/SPAN&gt;&lt;/I&gt;, instead uses &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #c0504d"&gt;&lt;A class="" title="Prototype based inheritance" href="http://en.wikipedia.org/wiki/Prototype-based_programming" target=_blank mce_href="http://en.wikipedia.org/wiki/Prototype-based_programming"&gt;prototype based inheritance&lt;/A&gt;&lt;/SPAN&gt;&lt;/I&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Times New Roman'"&gt;If Jscript does not have a formal notion of a &lt;SPAN style="COLOR: #c0504d"&gt;Class&lt;/SPAN&gt; then how does it support defining &lt;SPAN style="COLOR: #c0504d"&gt;Classes&lt;/SPAN&gt; and creating instances. This is what I am going to explain in this blog!!&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Times New Roman'"&gt;Jscript does not support true &lt;SPAN style="COLOR: #c0504d"&gt;Classes&lt;/SPAN&gt; the way most traditional languages do. However it is possible to simulate &lt;SPAN style="COLOR: #c0504d"&gt;Classes&lt;/SPAN&gt; in Jscript using &lt;SPAN style="COLOR: #c0504d"&gt;constructor functions&lt;/SPAN&gt; and &lt;SPAN style="COLOR: #c0504d"&gt;prototype objects&lt;/SPAN&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Times New Roman'"&gt;Let’s first define a few terms that we will use through this post:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #c0504d; FONT-FAMILY: 'Times New Roman'"&gt;Class&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;: (As in strongly typed languages) defines the structure of an object. It defines exactly what fields an object contains, their types and methods to operate upon the object.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;In Jscript, the types are not defined.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #c0504d; FONT-FAMILY: 'Times New Roman'"&gt;Constructor functions&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;: A function which is to be used with the &lt;SPAN style="COLOR: #c0504d"&gt;new&lt;/SPAN&gt; operator is called a &lt;SPAN style="COLOR: #c0504d"&gt;constructor&lt;I style="mso-bidi-font-style: normal"&gt; &lt;/I&gt;function&lt;/SPAN&gt; or simply &lt;SPAN style="COLOR: #c0504d"&gt;constructor&lt;/SPAN&gt;. Its job is to initialize a newly created object with any properties that need to be set before the object can be used. This object is then returned by the &lt;SPAN style="COLOR: #c0504d"&gt;new&lt;/SPAN&gt; operator.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #c0504d; FONT-FAMILY: 'Times New Roman'"&gt;Prototype objects&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;In Jscript, every object includes an internal reference to another object called as its prototype object except for original value of Object.prototype. Any properties of the prototype will appear as properties of the object for which it is the prototype. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;With this information, we are all set to implement our first &lt;SPAN style="COLOR: #c0504d"&gt;Class&lt;/SPAN&gt; in Jscript.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;We want to write a &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd"&gt;class Rectangle&lt;/SPAN&gt;&lt;/I&gt;, which has &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd"&gt;width&lt;/SPAN&gt;&lt;/I&gt; and &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd"&gt;height&lt;/SPAN&gt;&lt;/I&gt; as its data and a method &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd"&gt;area&lt;/SPAN&gt;&lt;/I&gt; that computes the area.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;First step would be to define the class. But there’s no &lt;SPAN style="COLOR: #c0504d"&gt;Class&lt;/SPAN&gt; keyword supported by JScript. So how do we do it? This is how we do it:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;Define a &lt;SPAN style="COLOR: #c0504d"&gt;constructor function&lt;/SPAN&gt; which initializes the required data.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;function Rectangle (ht, wt) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;this.height = ht;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;this.width=wt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;Next would be to create objects of type Rectangle.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;var rect1 = new Rectangle(5,10);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;var rect2 = new Rectangle(2,4);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;Then define a function which computes the area for the rectangle object.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;function computeArea(rObj) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;return rObj.height * rObj.width;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;Call the function to compute area.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;var rectArea = computeArea(rect1); //will return 50.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;But this is not object-oriented in its strict sense. A better approach would be to invoke a method on the Rectangle object rather than passing the object to a function. This can be done by adding a method in the definition of the class. The &lt;SPAN style="COLOR: #4f81bd"&gt;Rectangle constructor&lt;/SPAN&gt; would now look like:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;function Rectangle (ht, wt) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;this.height = ht;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;this.width=wt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;this.area = function() { return this.height * this.width;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;And the way area can be calculated for rect obj is:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;var rect1Area = rect1.area(); // rect1.area() will return 50.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;var rect2Area = rect2.area(); // rect2.area() will return 8.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;This is a much better object oriented implementation but still not the most optimal. Here every Rectangle object created will have three properties – &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd"&gt;height&lt;/SPAN&gt;&lt;/I&gt;, &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd"&gt;width&lt;/SPAN&gt;&lt;/I&gt; and &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd"&gt;area&lt;/SPAN&gt;&lt;/I&gt;. &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd"&gt;height&lt;/SPAN&gt;&lt;/I&gt; and &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd"&gt;width&lt;/SPAN&gt;&lt;/I&gt; for each &lt;SPAN style="COLOR: #4f81bd"&gt;Rectangle object&lt;/SPAN&gt; might differ but &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd"&gt;area&lt;/SPAN&gt;&lt;/I&gt; property would always refer to the same function object. What this means is &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd"&gt;area&lt;/SPAN&gt;&lt;/I&gt; property is going to be common for any number of Rectangle objects. Then why can’t we have &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd"&gt;area&lt;/SPAN&gt;&lt;/I&gt; as a shared property?&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;We can and this is where &lt;SPAN style="COLOR: #c0504d"&gt;prototype objects&lt;/SPAN&gt; come into picture:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;Let’s define &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd"&gt;area&lt;/SPAN&gt;&lt;/I&gt; as a property to the &lt;SPAN style="COLOR: #c0504d"&gt;prototype object&lt;/SPAN&gt; of &lt;SPAN style="COLOR: #4f81bd"&gt;Rectangle&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;Rectangle.prototype.area = function() {return this.height * this.width;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;rect1.area();&lt;/SPAN&gt;&lt;/I&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt; &lt;SPAN style="COLOR: #0070c0"&gt;// will return 50.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #0070c0; FONT-FAMILY: 'Times New Roman'"&gt;rect2.area();&lt;/SPAN&gt;&lt;/I&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt; &lt;SPAN style="COLOR: #0070c0"&gt;// will return 8.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;From all that we did so far we gather the following information:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; COLOR: #c0504d; FONT-FAMILY: 'Times New Roman'"&gt;Constructor&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt; provides the name for the &lt;SPAN style="COLOR: #c0504d"&gt;Class&lt;/SPAN&gt; and initializes the properties which can be different in every instance of the &lt;SPAN style="COLOR: #c0504d"&gt;Class&lt;/SPAN&gt;. The &lt;SPAN style="COLOR: #c0504d"&gt;prototype object&lt;/SPAN&gt; for &lt;SPAN style="COLOR: #4f81bd"&gt;Rectangle&lt;/SPAN&gt; is associated with its &lt;SPAN style="COLOR: #c0504d"&gt;constructor&lt;/SPAN&gt; and any properties defined by the &lt;SPAN style="COLOR: #c0504d"&gt;prototype object&lt;/SPAN&gt; are inherited by each and every object created using the &lt;SPAN style="COLOR: #c0504d"&gt;constructor&lt;/SPAN&gt;. Hence &lt;SPAN style="COLOR: #c0504d"&gt;prototype object&lt;/SPAN&gt; is the best place to define methods like &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd"&gt;area&lt;/SPAN&gt;&lt;/I&gt; which remain the same for all &lt;SPAN style="COLOR: #4f81bd"&gt;Rectangle objects&lt;/SPAN&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;This has couple of advantages: &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; TEXT-ALIGN: justify; mso-list: l1 level1 lfo1"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;·&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;Since all common methods (ones that can be shared by all objects) are defined as properties to the &lt;SPAN style="COLOR: #c0504d"&gt;prototype object&lt;/SPAN&gt; and are directly inherited by the objects, there is good amount of decrease in memory usage.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; TEXT-ALIGN: justify; mso-list: l1 level1 lfo1"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;·&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;In case a property is added to the &lt;SPAN style="COLOR: #c0504d"&gt;prototype object&lt;/SPAN&gt; after an object was created, then too the object would inherit the newly added property.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;Though all objects can read the properties of their &lt;SPAN style="COLOR: #c0504d"&gt;prototype object &lt;/SPAN&gt;without any issues, modifying them can cause certain issues.. Why is this so?&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;If rect1 goes and modifies &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd"&gt;area&lt;/SPAN&gt;&lt;/I&gt; property then any other object (rect2, rect3…) also get affected as they too would call the same &lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="COLOR: #4f81bd"&gt;area&lt;/SPAN&gt;&lt;/I&gt; property to compute the area. Still any code is allowed to modify properties defined on the prototype object as long as the&lt;SPAN style="mso-bidi-font-weight: bold"&gt; modification is directly on the prototype object itself, and not on the instance. Attempting to modify a prototype property on an instance creates a new property on the instance which overrides the prototype.&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;This is just the beginning for Classes in Jscript. In the later posts I would discuss the differences among &lt;SPAN style="COLOR: #c0504d"&gt;Instance Properties&lt;/SPAN&gt; &amp;amp; &lt;SPAN style="COLOR: #c0504d"&gt;Class Properties&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #c0504d"&gt;Instance Methods&lt;/SPAN&gt; &amp;amp; &lt;SPAN style="COLOR: #c0504d"&gt;Class Methods&lt;/SPAN&gt;. Another thing we will be looking at will be data encapsulation and inheritance.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;Hope you enjoyed this blog.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;Thanks,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;Ritesh&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=NoSpacing style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;SDET, JScript Team&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5091755" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jscript/archive/tags/JScript+Tutorial/default.aspx">JScript Tutorial</category><category domain="http://blogs.msdn.com/jscript/archive/tags/Object+Orientation+in+JScript/default.aspx">Object Orientation in JScript</category></item></channel></rss>